I added intl package and I trying to write out the screen


I am getting The argument type 'String' can't be assigned to the parameter type 'DateTime' error

Solution 1: Ravindra S. Patil

Try below code hope its help to you.

For Current Time Zone

DateTime now = DateTime.now();
String formattedDate = DateFormat('dd-MMM-yyyy ').format(now);

          'Date : ' + formattedDate,
          style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),

If you Use JSON format Date try below code

 String date = '';
 DateTime dateTime = DateTime.tryParse(
         date = DateFormat('dd-MM-yyyy').format(dateTime);


Solution 2: Josteve

The format method takes a DateTime and not a String

Assuming article.date is in an acceptable format for DateTime (Ignoring the data type).

Try this: