From a63e19ba0f6e55fa010e3e5d0d3b022b04849a87 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Mon, 23 Jan 2023 11:26:07 -0800 Subject: [PATCH] Remove unnecessary null checks in flutter_localizations (#118863) --- .../lib/src/cupertino_localizations.dart | 11 +---------- .../lib/src/material_localizations.dart | 14 +------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/packages/flutter_localizations/lib/src/cupertino_localizations.dart b/packages/flutter_localizations/lib/src/cupertino_localizations.dart index a07ddb9998f..7fec5fe50e0 100644 --- a/packages/flutter_localizations/lib/src/cupertino_localizations.dart +++ b/packages/flutter_localizations/lib/src/cupertino_localizations.dart @@ -63,23 +63,14 @@ abstract class GlobalCupertinoLocalizations implements CupertinoLocalizations { required intl.DateFormat doubleDigitMinuteFormat, required intl.DateFormat singleDigitSecondFormat, required intl.NumberFormat decimalFormat, - }) : assert(localeName != null), - _localeName = localeName, - assert(fullYearFormat != null), + }) : _localeName = localeName, _fullYearFormat = fullYearFormat, - assert(dayFormat != null), _dayFormat = dayFormat, - assert(mediumDateFormat != null), _mediumDateFormat = mediumDateFormat, - assert(singleDigitHourFormat != null), _singleDigitHourFormat = singleDigitHourFormat, - assert(singleDigitMinuteFormat != null), _singleDigitMinuteFormat = singleDigitMinuteFormat, - assert(doubleDigitMinuteFormat != null), _doubleDigitMinuteFormat = doubleDigitMinuteFormat, - assert(singleDigitSecondFormat != null), _singleDigitSecondFormat = singleDigitSecondFormat, - assert(decimalFormat != null), _decimalFormat =decimalFormat; final String _localeName; diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 56875a0c5e4..477940e3849 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -97,25 +97,15 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations { required intl.DateFormat shortMonthDayFormat, required intl.NumberFormat decimalFormat, required intl.NumberFormat twoDigitZeroPaddedFormat, - }) : assert(localeName != null), - _localeName = localeName, - assert(fullYearFormat != null), + }) : _localeName = localeName, _fullYearFormat = fullYearFormat, - assert(compactDateFormat != null), _compactDateFormat = compactDateFormat, - assert(shortDateFormat != null), _shortDateFormat = shortDateFormat, - assert(mediumDateFormat != null), _mediumDateFormat = mediumDateFormat, - assert(longDateFormat != null), _longDateFormat = longDateFormat, - assert(yearMonthFormat != null), _yearMonthFormat = yearMonthFormat, - assert(shortMonthDayFormat != null), _shortMonthDayFormat = shortMonthDayFormat, - assert(decimalFormat != null), _decimalFormat = decimalFormat, - assert(twoDigitZeroPaddedFormat != null), _twoDigitZeroPaddedFormat = twoDigitZeroPaddedFormat; final String _localeName; @@ -298,7 +288,6 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations { String pageRowsInfoTitle(int firstRow, int lastRow, int rowCount, bool rowCountIsApproximate) { String? text = rowCountIsApproximate ? pageRowsInfoTitleApproximateRaw : null; text ??= pageRowsInfoTitleRaw; - assert(text != null, 'A $_localeName localization was not found for pageRowsInfoTitle or pageRowsInfoTitleApproximate'); return text .replaceFirst(r'$firstRow', formatDecimal(firstRow)) .replaceFirst(r'$lastRow', formatDecimal(lastRow)) @@ -446,7 +435,6 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations { /// the short time pattern used in the `en_US` locale. @override TimeOfDayFormat timeOfDayFormat({ bool alwaysUse24HourFormat = false }) { - assert(alwaysUse24HourFormat != null); if (alwaysUse24HourFormat) { return _get24HourVersionOf(timeOfDayFormatRaw); }