i18n icon indicating copy to clipboard operation
i18n copied to clipboard

`initializeDateFormatting` examples in the documentation use null when not allowed

Open jamesderlin opened this issue 2 years ago • 3 comments

The DateFormat documentation (as of intl 0.18.1) includes examples for calling initializeDateFormatting:

import 'package:intl/date_symbol_data_file.dart';
initializeDateFormatting('de_DE', null).then((_) => runMyCode());
import 'package:intl/date_symbol_data_http_request.dart';
initializeDateFormatting('pt_BR', null).then((_) => runMyCode());

Those examples are no longer legal since those two implementations of initializeDateFormatting take a non-null String as their second argument. (However, note that the implementation from date_symbol_data_local.dart does have nullable parameter types.)

jamesderlin avatar Nov 10 '23 17:11 jamesderlin

The fact that the documentation is wrong brings me to the problem that I do not understand how to initialize intl correctly.

I alway get the error:

"Locale en_US has not been initialized. Call initializeDateFormatting(en_US, data url) first"

But I do not know what to use as "data url".

Kuhlemann avatar Apr 18 '24 20:04 Kuhlemann

But I do not know what to use as "data url".

Is your import for initializeDateFormatting from import 'package:intl/date_symbol_data_local.dart';?

mosuem avatar Apr 22 '24 13:04 mosuem

Thanks, my error was using import 'package:intl/date_symbol_data_file.dart'; instead of ..._local

Kuhlemann avatar May 01 '24 12:05 Kuhlemann