@@ -94,7 +94,7 @@ class Intl {
94
94
/// [Intl.withLocale] may be preferable if you are using different locales
95
95
/// in the same application.
96
96
static String get defaultLocale {
97
- var zoneLocale = Zone .current[#Intl .locale];
97
+ var zoneLocale = Zone .current[#Intl .locale] as String ;
98
98
return zoneLocale == null ? _defaultLocale : zoneLocale;
99
99
}
100
100
@@ -207,8 +207,9 @@ class Intl {
207
207
///
208
208
/// Note that null is interpreted as meaning the default locale, so if
209
209
/// [newLocale] is null the default locale will be returned.
210
- static String verifiedLocale (String newLocale, Function localeExists,
211
- {Function onFailure: _throwLocaleError}) {
210
+ static String verifiedLocale (
211
+ String newLocale, bool Function (String ) localeExists,
212
+ {String Function (String ) onFailure: _throwLocaleError}) {
212
213
// TODO(alanknight): Previously we kept a single verified locale on the Intl
213
214
// object, but with different verification for different uses, that's more
214
215
// difficult. As a result, we call this more often. Consider keeping
@@ -340,8 +341,15 @@ class Intl {
340
341
341
342
/// Internal: Implements the logic for plural selection - use [plural] for
342
343
/// normal messages.
343
- static pluralLogic (num howMany,
344
- {zero, one, two, few, many, other, String locale, int precision,
344
+ static T pluralLogic <T >(num howMany,
345
+ {T zero,
346
+ T one,
347
+ T two,
348
+ T few,
349
+ T many,
350
+ T other,
351
+ String locale,
352
+ int precision,
345
353
String meaning}) {
346
354
if (other == null ) {
347
355
throw new ArgumentError ("The 'other' named argument must be provided" );
@@ -549,7 +557,10 @@ class Intl {
549
557
/// desc: 'Say Hello');
550
558
/// Intl.withLocale("zh", new Timer(new Duration(milliseconds:10),
551
559
/// () => print(hello("World")));
552
- static withLocale (String locale, function ()) {
560
+ static dynamic withLocale <T >(String locale, T Function () function) {
561
+ // TODO(alanknight): Make this return T. This requires work because T might
562
+ // be Future and the caller could get an unawaited Future. Which is
563
+ // probably an error in their code, but the change is semi-breaking.
553
564
var canonical = Intl .canonicalizedLocale (locale);
554
565
return runZoned (function, zoneValues: {#Intl .locale: canonical});
555
566
}
0 commit comments