intl: Fix analysis errors, fix some implicit dynamic cases

Fix various things that dartanalyzer complained about.  I'm disabling
`prefer_single_quotes` for now since there are too many existing
double-quoted strings.

Also fix a few cases where variables were implicitly dynamic. (There
are many, many more cases.)

PiperOrigin-RevId: 309988848
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 76203fd..81ede1d 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,9 +1,13 @@
 analyzer:
+  language:
+    strict-raw-types: true
+
   exclude:
      - test/number_format_compact_icu_test.dart # TODO(240): Update for FFI changes
 
 errors:
     dead_code: error
+    missing_required_param: error
     override_on_non_overriding_method: error
     unused_element: error
     unused_import: error
@@ -64,7 +68,6 @@
     - prefer_is_empty
     - prefer_is_not_empty
     - prefer_null_aware_operators
-    - prefer_single_quotes
     - prefer_typing_uninitialized_variables
     - recursive_getters
     - slash_for_doc_comments
diff --git a/lib/message_format.dart b/lib/message_format.dart
index 86d4d7b..44b68e9 100644
--- a/lib/message_format.dart
+++ b/lib/message_format.dart
@@ -604,10 +604,7 @@
       argumentName = match.group(1);
       return '';
     });
-    // The lint complaints about "Omit type annotations for local variables"
-    // But if I make this `var` then it assumes that the value is a
-    // always a string, but it is not.
-    Map<String, Object> result = {'argumentName': argumentName};
+    var result = <String, Object>{'argumentName': argumentName};
 
     var parts = _extractParts(pattern);
     // Looking for (key block)+ sequence. One of the keys has to be "other".
diff --git a/lib/src/intl/date_format_field.dart b/lib/src/intl/date_format_field.dart
index e15e685..22e00f9 100644
--- a/lib/src/intl/date_format_field.dart
+++ b/lib/src/intl/date_format_field.dart
@@ -414,7 +414,7 @@
   ///
   /// This method handles reading any of the numeric fields. The [offset]
   /// argument allows us to compensate for zero-based versus one-based values.
-  void handleNumericField(_Stream input, void Function(num) setter,
+  void handleNumericField(_Stream input, void Function(int) setter,
       [int offset = 0]) {
     var result = input.nextInteger(
         digitMatcher: parent.digitMatcher,
@@ -456,7 +456,7 @@
     }
   }
 
-  void parseMonth(input, dateFields) {
+  void parseMonth(_Stream input, _DateBuilder dateFields) {
     List<String> possibilities;
     switch (width) {
       case 5:
diff --git a/lib/src/intl/date_format_helpers.dart b/lib/src/intl/date_format_helpers.dart
index c0b7f13..e9c0ec6 100644
--- a/lib/src/intl/date_format_helpers.dart
+++ b/lib/src/intl/date_format_helpers.dart
@@ -81,19 +81,19 @@
 
   // Functions that exist just to be closurized so we can pass them to a general
   // method.
-  void setYear(x) {
+  void setYear(int x) {
     year = x;
   }
 
-  void setMonth(x) {
+  void setMonth(int x) {
     month = x;
   }
 
-  void setDay(x) {
+  void setDay(int x) {
     day = x;
   }
 
-  void setDayOfYear(x) {
+  void setDayOfYear(int x) {
     dayOfYear = x;
   }
 
@@ -101,19 +101,19 @@
   /// the day of the month.
   int get dayOrDayOfYear => dayOfYear == 0 ? day : dayOfYear;
 
-  void setHour(x) {
+  void setHour(int x) {
     hour = x;
   }
 
-  void setMinute(x) {
+  void setMinute(int x) {
     minute = x;
   }
 
-  void setSecond(x) {
+  void setSecond(int x) {
     second = x;
   }
 
-  void setFractionalSecond(x) {
+  void setFractionalSecond(int x) {
     fractionalSecond = x;
   }
 
@@ -336,7 +336,7 @@
 
   /// Find the index of the first element for which [f] returns true.
   /// Advances the stream to that position.
-  int findIndex(Function f) {
+  int findIndex(bool Function(dynamic) f) {
     while (!atEnd()) {
       if (f(next())) return index - 1;
     }
@@ -345,7 +345,7 @@
 
   /// Find the indexes of all the elements for which [f] returns true.
   /// Leaves the stream positioned at the end.
-  List<dynamic> findIndexes(Function f) {
+  List<dynamic> findIndexes(bool Function(dynamic) f) {
     var results = [];
     while (!atEnd()) {
       if (f(next())) results.add(index - 1);
diff --git a/lib/src/intl_helpers.dart b/lib/src/intl_helpers.dart
index a807d97..356d00c 100644
--- a/lib/src/intl_helpers.dart
+++ b/lib/src/intl_helpers.dart
@@ -68,7 +68,12 @@
 
   List<String> get keys => _throwException() as List<String>;
 
-  bool containsKey(String key) => _isFallback(key) ? true : _throwException();
+  bool containsKey(String key) {
+    if (!_isFallback(key)) {
+      _throwException();
+    }
+    return true;
+  }
 
   F _throwException() {
     throw LocaleDataException('Locale data has not been initialized'
diff --git a/lib/src/lazy_locale_data.dart b/lib/src/lazy_locale_data.dart
index 0469ef6..0620033 100644
--- a/lib/src/lazy_locale_data.dart
+++ b/lib/src/lazy_locale_data.dart
@@ -41,7 +41,7 @@
   /// [keys] lists the set of remotely available locale names so we know which
   /// things can be fetched without having to check remotely.
   LazyLocaleData(this._reader, this._creationFunction, this.availableLocales) {
-    map = Map();
+    map = {};
     availableLocaleSet = Set.from(availableLocales);
   }
 
@@ -58,7 +58,7 @@
   /// [localeName] then throw an exception with a different message.
   dynamic operator [](String localeName) {
     if (containsKey(localeName)) {
-      var data = map[localeName];
+      dynamic data = map[localeName];
       if (data == null) {
         throw LocaleDataException('Locale $localeName has not been initialized.'
             ' Call initializeDateFormatting($localeName, <data url>) first');
@@ -72,7 +72,7 @@
 
   /// Throw an exception indicating that the locale has no data available,
   /// either locally or remotely.
-  void unsupportedLocale(localeName) {
+  void unsupportedLocale(String localeName) {
     throw LocaleDataException('Locale $localeName has no data available');
   }
 
diff --git a/lib/src/plural_rules.dart b/lib/src/plural_rules.dart
index 1a3beb5..656bf62 100644
--- a/lib/src/plural_rules.dart
+++ b/lib/src/plural_rules.dart
@@ -75,7 +75,7 @@
 
   _v = precision ?? math.min(_decimals(n, precision), defaultDigits);
 
-  int base = math.pow(10, _v);
+  var base = math.pow(10, _v) as int;
   _f = (n * base).floor() % base;
 }
 
@@ -444,7 +444,7 @@
 }
 
 /// Selected Plural rules by locale.
-final Map pluralRules = {
+final pluralRules = {
   'af': _es_rule,
   'am': _hi_rule,
   'ar': _ar_rule,
diff --git a/test/date_time_strict_test.dart b/test/date_time_strict_test.dart
index daed8c3..730ceeb 100644
--- a/test/date_time_strict_test.dart
+++ b/test/date_time_strict_test.dart
@@ -67,7 +67,7 @@
 
   test('Invalid times 24 hour', () {
     var format = DateFormat.Hms();
-    check(s) => expect(() => format.parseStrict(s), throwsFormatException);
+    void check(s) => expect(() => format.parseStrict(s), throwsFormatException);
     check('-1:15:00');
     expect(format.parseStrict('0:15:00'), DateTime(1970, 1, 1, 0, 15));
     check('24:00:00');
diff --git a/test/more_compact_number_test_data.dart b/test/more_compact_number_test_data.dart
index 0c3bf8b..b443c0d 100644
--- a/test/more_compact_number_test_data.dart
+++ b/test/more_compact_number_test_data.dart
@@ -13,12 +13,12 @@
 
   num number;
   String expected;
-  int maximumIntegerDigits = null;
-  int minimumIntegerDigits = null;
-  int maximumFractionDigits = null;
-  int minimumFractionDigits = null;
-  int minimumExponentDigits = null;
-  int significantDigits = null;
+  int maximumIntegerDigits;
+  int minimumIntegerDigits;
+  int maximumFractionDigits;
+  int minimumFractionDigits;
+  int minimumExponentDigits;
+  int significantDigits;
 
   String toString() => "CompactRoundingTestCase for $number, "
       "maxIntDig: $maximumIntegerDigits, "
diff --git a/test/number_format_compact_test.dart b/test/number_format_compact_test.dart
index 91bf801..a1e44bb 100644
--- a/test/number_format_compact_test.dart
+++ b/test/number_format_compact_test.dart
@@ -314,19 +314,30 @@
 }
 
 void validateFancy(more_testdata.CompactRoundingTestCase t) {
-  var shortFormat = new NumberFormat.compact(locale: 'en');
-  if (t.maximumIntegerDigits != null)
+  var shortFormat = NumberFormat.compact(locale: 'en');
+  if (t.maximumIntegerDigits != null) {
     shortFormat.maximumIntegerDigits = t.maximumIntegerDigits;
-  if (t.minimumIntegerDigits != null)
+  }
+
+  if (t.minimumIntegerDigits != null) {
     shortFormat.minimumIntegerDigits = t.minimumIntegerDigits;
-  if (t.maximumFractionDigits != null)
+  }
+
+  if (t.maximumFractionDigits != null) {
     shortFormat.maximumFractionDigits = t.maximumFractionDigits;
-  if (t.minimumFractionDigits != null)
+  }
+
+  if (t.minimumFractionDigits != null) {
     shortFormat.minimumFractionDigits = t.minimumFractionDigits;
-  if (t.minimumExponentDigits != null)
+  }
+
+  if (t.minimumExponentDigits != null) {
     shortFormat.minimumExponentDigits = t.minimumExponentDigits;
-  if (t.significantDigits != null)
+  }
+
+  if (t.significantDigits != null) {
     shortFormat.significantDigits = t.significantDigits;
+  }
 
   test(t.toString(), () {
     expect(shortFormat.format(t.number), t.expected);
diff --git a/test/number_format_compact_web_test.dart b/test/number_format_compact_web_test.dart
index 46d608f..a6c60e1 100644
--- a/test/number_format_compact_web_test.dart
+++ b/test/number_format_compact_web_test.dart
@@ -8,7 +8,7 @@
 /// We use @Tags rather than @TestOn to be able to specify something that can be
 /// ignored when using a build system that can't read dart_test.yaml. This
 /// depends on https://github.com/tc39/proposal-unified-intl-numberformat.
-@Tags(const ['unifiedNumberFormat'])
+@Tags(['unifiedNumberFormat'])
 
 import 'package:intl/intl.dart' as intl;
 import 'package:js/js_util.dart' as js;
@@ -17,7 +17,7 @@
 import 'compact_number_test_data.dart' as testdata35;
 import 'more_compact_number_test_data.dart' as more_testdata;
 
-main() {
+void main() {
   testdata35.compactNumberTestData.forEach(validate);
   more_testdata.cldr35CompactNumTests.forEach(validateMore);
 
@@ -62,14 +62,12 @@
 }
 
 String ecmaFormatNumber(String locale, num number,
-    {String style: null,
-    String currency: null,
-    String notation: null,
-    String compactDisplay: null}) {
+    {String style, String currency, String notation, String compactDisplay}) {
   var options = js.newObject();
   if (notation != null) js.setProperty(options, 'notation', notation);
-  if (compactDisplay != null)
+  if (compactDisplay != null) {
     js.setProperty(options, 'compactDisplay', compactDisplay);
+  }
   if (style != null) js.setProperty(options, 'style', style);
   if (currency != null) js.setProperty(options, 'currency', currency);
   return js.callMethod(number, 'toLocaleString', [locale, options]);
@@ -131,16 +129,26 @@
 void validateMore(more_testdata.CompactRoundingTestCase t) {
   var options = js.newObject();
   js.setProperty(options, 'notation', 'compact');
-  if (t.maximumIntegerDigits != null)
+  if (t.maximumIntegerDigits != null) {
     js.setProperty(options, 'maximumIntegerDigits', t.maximumIntegerDigits);
-  if (t.minimumIntegerDigits != null)
+  }
+
+  if (t.minimumIntegerDigits != null) {
     js.setProperty(options, 'minimumIntegerDigits', t.minimumIntegerDigits);
-  if (t.maximumFractionDigits != null)
+  }
+
+  if (t.maximumFractionDigits != null) {
     js.setProperty(options, 'maximumFractionDigits', t.maximumFractionDigits);
-  if (t.minimumFractionDigits != null)
+  }
+
+  if (t.minimumFractionDigits != null) {
     js.setProperty(options, 'minimumFractionDigits', t.minimumFractionDigits);
-  if (t.minimumExponentDigits != null)
+  }
+
+  if (t.minimumExponentDigits != null) {
     js.setProperty(options, 'minimumExponentDigits', t.minimumExponentDigits);
+  }
+
   if (t.significantDigits != null) {
     js.setProperty(options, 'minimumSignificantDigits', t.significantDigits);
     js.setProperty(options, 'maximumSignificantDigits', t.significantDigits);
diff --git a/test/number_format_test_core.dart b/test/number_format_test_core.dart
index b2961cd..372b555 100644
--- a/test/number_format_test_core.dart
+++ b/test/number_format_test_core.dart
@@ -130,7 +130,7 @@
       '9,876,543,210',
     ];
     for (var i = 0; i < expected.length; i++) {
-      var f = new NumberFormat.decimalPattern();
+      var f = NumberFormat.decimalPattern();
       f.maximumIntegerDigits = i;
       expect(f.format(9876543210), expected[i],
           reason: 'maximumIntegerDigits: $i');
@@ -148,7 +148,7 @@
       '1.000000',
     ];
     for (var i = 0; i < 6; i++) {
-      var f = new NumberFormat.decimalPattern();
+      var f = NumberFormat.decimalPattern();
       f.minimumFractionDigits = i;
       if (i > f.maximumFractionDigits) f.maximumFractionDigits = i;
       expect(f.format(1), expected[i],
@@ -173,7 +173,7 @@
       '9.123456789',
     ];
     for (var i = 0; i < expected.length; i++) {
-      var f = new NumberFormat.decimalPattern();
+      var f = NumberFormat.decimalPattern();
       f.maximumFractionDigits = i;
       expect(f.format(9.123456789), expected[i],
           reason: 'maximumFractionDigits: $i');
@@ -198,7 +198,7 @@
       '3.21E003',
     ];
     for (var i = 0; i < expected.length; i++) {
-      var f = new NumberFormat("#.###E0");
+      var f = NumberFormat("#.###E0");
       f.minimumExponentDigits = i;
       expect(f.format(3210), expected[i], reason: 'minimumExponentDigits: $i');
     }
@@ -222,7 +222,7 @@
       '9,876,543.21012',
     ];
     for (var i = 0; i < expected.length; i++) {
-      var f = new NumberFormat.decimalPattern();
+      var f = NumberFormat.decimalPattern();
       f.significantDigits = i;
       expect(f.format(9876543.21012), expected[i],
           reason: 'significantDigits: $i');