Skip to content

Conversation

shihaohong
Copy link
Contributor

@shihaohong shihaohong commented Apr 16, 2021

Fixes #80564.

  1. Makes the time picker widget state restorable by exposing TimePickerDialog and adding state restoration framework support.
  2. Adds a new RestorableTimeOfDay class that is helpful when used in tandem with TimePickerDialog.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 16, 2021
@google-cla google-cla bot added the cla: yes label Apr 16, 2021
@shihaohong shihaohong changed the title [State Restoration][WIP] Time Picker [State Restoration] Time Picker Apr 20, 2021
@shihaohong shihaohong changed the title [State Restoration] Time Picker [State Restoration] Restorable TimePickerDialog, RestorableTimeOfDay Apr 20, 2021
@shihaohong shihaohong changed the title [State Restoration] Restorable TimePickerDialog, RestorableTimeOfDay [State Restoration] Restorable TimePickerDialog widget, RestorableTimeOfDay Apr 20, 2021
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 169 to 172
Object? toPrimitives() => <String, int>{
'minute': value.minute,
'hour': value.hour,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could eliminate the keys and just store this as:

Suggested change
Object? toPrimitives() => <String, int>{
'minute': value.minute,
'hour': value.hour,
};
Object? toPrimitives() => <int>[value.minute, value.hour];

... with a corresponding change in fromPrimitives.

Comment on lines 1652 to 1659
@override
String? get restorationId => widget.restorationId;

@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(controller, 'text_editing_controller');
registerForRestoration(controllerHasBeenSet, 'has_controller_been_set');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's move these below the block of field declarations below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[State Restoration] Material Time Picker
3 participants