In Book : Flutter Apprentice First Edition, I had below code:
import 'package:flutter/painting.dart';
// 1
enum Importance { low, medium, high }
class GroceryItem {
// 2
final String id;
// 3
final String name;
final Importance importance;
final Color color;
final int quantity;
final DateTime date;
final bool isComplete;
...
And the build method as
Widget buildDate() {
final dateFormatter = DateFormat('MMMM dd h:mm a');
final dateString = dateFormatter.format(item!.date);
return Text(
dateString,
style: TextStyle(decoration: textDecoration),
);
}
I have the below error:
The argument type 'DateTime?' can't be assigned to the parameter type 'DateTime'.
This removed the error-
final dateString = dateFormatter.format(item!.date as DateTime);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With