Commit 6d135e45 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Eliminate extraneous bool in DatePicker haptic feedback (#8337)

parent c8f8d001
......@@ -591,8 +591,6 @@ class _DatePickerDialog extends StatefulWidget {
}
class _DatePickerDialogState extends State<_DatePickerDialog> {
bool _vibrate = false;
@override
void initState() {
super.initState();
......@@ -603,17 +601,26 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
_DatePickerMode _mode = _DatePickerMode.day;
GlobalKey _pickerKey = new GlobalKey();
void _vibrate() {
switch (Theme.of(context).platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
HapticFeedback.vibrate();
break;
case TargetPlatform.iOS:
break;
}
}
void _handleModeChanged(_DatePickerMode mode) {
if (_vibrate)
HapticFeedback.vibrate();
_vibrate();
setState(() {
_mode = mode;
});
}
void _handleYearChanged(DateTime value) {
if (_vibrate)
HapticFeedback.vibrate();
_vibrate();
setState(() {
_mode = _DatePickerMode.day;
_selectedDate = value;
......@@ -621,8 +628,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
}
void _handleDayChanged(DateTime value) {
if (_vibrate)
HapticFeedback.vibrate();
_vibrate();
setState(() {
_selectedDate = value;
});
......@@ -662,15 +668,6 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
@override
Widget build(BuildContext context) {
switch (Theme.of(context).platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
_vibrate = true;
break;
case TargetPlatform.iOS:
_vibrate = false;
break;
}
Widget picker = new Flexible(
child: new SizedBox(
height: _kMaxDayPickerHeight,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment