Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter intl 0.17.0-nullsafety.2 package initializeDateFormatting

Tags:

flutter

dart

intl

i need some help because im going crazy. I just want to format date to my locale (should be it-IT).

In flutter app i putted in pubspec.yaml the intl package with the new nullsafety feature:

  flutter:
    sdk: flutter
  intl: ^0.17.0-nullsafety.2 

looking into the documentation it says:

<< Note that before doing any DateTime formatting for a particular locale, you must load the appropriate data by calling: >>

import 'package:intl/date_symbol_data_local.dart';
...
initializeDateFormatting('de_DE', null).then(formatDates); 

(https://pub.dev/packages/intl/versions/0.17.0-nullsafety.2)

so, just to try, i did:

initializeDateFormatting('it-IT', null).then((value) => {print('intl ok')});

but the dart nullsafety doesnt want a null parameter, and it says "The argument type 'Null' can't be assigned to the parameter type 'String'."

Any suggestion?

like image 686
Francesco Avatar asked Mar 19 '26 18:03

Francesco


1 Answers

I was facing the same issue.

Changed import statement to

import 'package:intl/date_symbol_data_local.dart';

from

import 'package:intl/date_symbol_data_file.dart';

Also dependency I am using is intl: ^0.18.1

like image 120
Aditya Agarwal Avatar answered Mar 22 '26 08:03

Aditya Agarwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!