Home > other >  Why flutter give an error 'Undefined name DateFormat"?
Why flutter give an error 'Undefined name DateFormat"?

Time:10-03

How can I fix it? Please don't say import intl.dart as you can see at the second photo I already add it.

1

2

CodePudding user response:

Your import statement has a red line under it. Meaning it has an error. Most likely you didn't include intl in your dependencies. You need to add this in the dependencies section of your pubspec.yaml file.

intl: ^0.17.0

CodePudding user response:

It might be using the Date Format class from another package.

-> import 'package:intl/intl.dart' as intl;

Edit the import like this.

Try using the date format as below.

intl.DateFormat.yMMMd().format(transaction[index].date),

CodePudding user response:

Open your terminal in VSCode (Ctrl Shift ') then type flutter pub add intl to add the intl package on your dependencies.

  • Related