Add null safety check before displaying SnackBar (#1866)

pull/1867/head
Biso 1 year ago committed by GitHub
parent 0083ceb353
commit 51223a0efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1475,9 +1475,12 @@ class _TimePickersState extends State<TimePickers> {
); );
setState(() { setState(() {
selectedTime = time; selectedTime = time;
if (selectedTime != null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Selected time: ${selectedTime!.format(context)}'), content:
Text('Selected time: ${selectedTime!.format(context)}'),
)); ));
}
}); });
}, },
child: const Text( child: const Text(

@ -1475,9 +1475,12 @@ class _TimePickersState extends State<TimePickers> {
); );
setState(() { setState(() {
selectedTime = time; selectedTime = time;
if (selectedTime != null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Selected time: ${selectedTime!.format(context)}'), content:
Text('Selected time: ${selectedTime!.format(context)}'),
)); ));
}
}); });
}, },
child: const Text( child: const Text(

Loading…
Cancel
Save