Closed pamtbaau closed 4 days ago
Describe the bug A clear and concise description of what the bug is.
When changing the value of a DatePicker by scrolling the date, an exception is thrown when setState() is called in onChanged.
DatePicker
setState()
onChanged
Workaround until fixed: Wrap setState() inside a Future.delayed():
Future.delayed()
onChanged: (value) { Future.delayed(const Duration(milliseconds: 500), () { setState(() { selected = value; }); }); },
To Reproduce Steps to reproduce the behavior:
fluent_ui: git: https://github.com/bdlukaa/fluent_ui.git
Update main.dart as follows:
main.dart
import 'package:fluent_ui/fluent_ui.dart'; void main() async { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return FluentApp( title: 'Bug issue', home: NavigationView( pane: NavigationPane( selected: 0, displayMode: PaneDisplayMode.compact, items: [ PaneItem( icon: const Icon(FluentIcons.home), title: const Text('Home'), body: Container( alignment: Alignment.center, child: const DateWidget(), ), ), ], ), ), ); } } class DateWidget extends StatefulWidget { const DateWidget({super.key}); @override State<DateWidget> createState() => DateWidgetState(); } class DateWidgetState extends State<DateWidget> { DateTime selected = DateTime.now(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return DatePicker( selected: selected, fieldOrder: const [ DatePickerField.year, DatePickerField.month, DatePickerField.day, ], onChanged: (value) { setState(() { selected = value; }); }, ); } }
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
We are calling onChanged before popping the picker. I believe changing this order fixes this issue.
I see the same issue.
Describe the bug A clear and concise description of what the bug is.
When changing the value of a
DatePicker
by scrolling the date, an exception is thrown whensetState()
is called inonChanged
.Workaround until fixed: Wrap
setState()
inside aFuture.delayed()
:To Reproduce Steps to reproduce the behavior:
Update
main.dart
as follows:Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.