Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
♻️ migrate codebase to nullsafety
Browse files Browse the repository at this point in the history
  • Loading branch information
jozsefsallai committed Jun 24, 2021
1 parent 1e68bc3 commit b0f8d93
Show file tree
Hide file tree
Showing 564 changed files with 8,109 additions and 7,941 deletions.
4 changes: 4 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "cirrusci/flutter:beta",
"forwardPorts": [ 5000 ]
}
6 changes: 3 additions & 3 deletions bin/split_locales.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
translationStrings[mainKey] = {};
}

translationStrings[mainKey][translationKey] = json[key];
translationStrings[mainKey]![translationKey] = json[key];

if (!mainKey.startsWith('@') && !mainKeys.contains(mainKey)) {
mainKeys.add(mainKey);
Expand All @@ -30,9 +30,9 @@ void main() {
var output = {};
var current = translationStrings[mainKey];

current.keys.forEach((key) {
current?.keys.forEach((key) {
output[key] = current[key];
output['@$key'] = translationStrings['@$mainKey'][key];
output['@$key'] = translationStrings['@$mainKey']![key];
});

var str = jsonEncoder.convert(output);
Expand Down
45 changes: 30 additions & 15 deletions lib/delegates/es_es_localizations_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ class MaterialLocalizationEsES extends MaterialLocalizationEs {

const MaterialLocalizationEsES({
String localeName = 'es-ES',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat longDateFormat,
@required intl.DateFormat yearMonthFormat,
@required intl.NumberFormat decimalFormat,
@required intl.NumberFormat twoDigitZeroPaddedFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat shortDateFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat longDateFormat,
required intl.DateFormat compactDateFormat,
required intl.DateFormat yearMonthFormat,
required intl.DateFormat shortMonthDayFormat,
required intl.NumberFormat decimalFormat,
required intl.NumberFormat twoDigitZeroPaddedFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat,
);
Expand All @@ -37,23 +43,32 @@ class MaterialLocalizationEsESDelegate extends LocalizationsDelegate<MaterialLoc
@override
Future<MaterialLocalizationEsES> load(Locale locale) {
intl.DateFormat fullYearFormat;
intl.DateFormat shortDateFormat;
intl.DateFormat mediumDateFormat;
intl.DateFormat longDateFormat;
intl.DateFormat compactDateFormat;
intl.DateFormat yearMonthFormat;
intl.DateFormat shortMonthDayFormat;
intl.NumberFormat decimalFormat;
intl.NumberFormat twoDigitZeroPaddedFormat;
decimalFormat = intl.NumberFormat.decimalPattern(locale.languageCode);
twoDigitZeroPaddedFormat = intl.NumberFormat('00', locale.languageCode);
fullYearFormat = intl.DateFormat.y(locale.languageCode);
shortDateFormat = intl.DateFormat.MEd(locale.languageCode);
mediumDateFormat = intl.DateFormat.MMMEd(locale.languageCode);
longDateFormat = intl.DateFormat.yMMMMEEEEd(locale.languageCode);
compactDateFormat = intl.DateFormat.MEd(locale.languageCode);
yearMonthFormat = intl.DateFormat.yMMMM(locale.languageCode);
shortMonthDayFormat = intl.DateFormat.Md(locale.languageCode);

return SynchronousFuture(MaterialLocalizationEsES(
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat
));
Expand All @@ -66,14 +81,14 @@ class CupertinoLocalizationEsES extends CupertinoLocalizationEs {

const CupertinoLocalizationEsES({
String localeName = 'es-ES',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat dayFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat singleDigitHourFormat,
@required intl.DateFormat singleDigitMinuteFormat,
@required intl.DateFormat doubleDigitMinuteFormat,
@required intl.DateFormat singleDigitSecondFormat,
@required intl.NumberFormat decimalFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat dayFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat singleDigitHourFormat,
required intl.DateFormat singleDigitMinuteFormat,
required intl.DateFormat doubleDigitMinuteFormat,
required intl.DateFormat singleDigitSecondFormat,
required intl.NumberFormat decimalFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
Expand Down Expand Up @@ -131,4 +146,4 @@ class CupertinoLocalizationEsESDelegate extends LocalizationsDelegate<CupertinoL
@override
bool shouldReload(CupertinoLocalizationEsESDelegate old) => false;

}
}
45 changes: 30 additions & 15 deletions lib/delegates/pt_br_localizations_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ class MaterialLocalizationPtBR extends MaterialLocalizationPt {

const MaterialLocalizationPtBR({
String localeName = 'pt-BR',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat longDateFormat,
@required intl.DateFormat yearMonthFormat,
@required intl.NumberFormat decimalFormat,
@required intl.NumberFormat twoDigitZeroPaddedFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat shortDateFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat longDateFormat,
required intl.DateFormat compactDateFormat,
required intl.DateFormat yearMonthFormat,
required intl.DateFormat shortMonthDayFormat,
required intl.NumberFormat decimalFormat,
required intl.NumberFormat twoDigitZeroPaddedFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat,
);
Expand All @@ -37,23 +43,32 @@ class MaterialLocalizationPtBRDelegate extends LocalizationsDelegate<MaterialLoc
@override
Future<MaterialLocalizationPtBR> load(Locale locale) {
intl.DateFormat fullYearFormat;
intl.DateFormat shortDateFormat;
intl.DateFormat mediumDateFormat;
intl.DateFormat longDateFormat;
intl.DateFormat compactDateFormat;
intl.DateFormat yearMonthFormat;
intl.DateFormat shortMonthDayFormat;
intl.NumberFormat decimalFormat;
intl.NumberFormat twoDigitZeroPaddedFormat;
decimalFormat = intl.NumberFormat.decimalPattern(locale.languageCode);
twoDigitZeroPaddedFormat = intl.NumberFormat('00', locale.languageCode);
fullYearFormat = intl.DateFormat.y(locale.languageCode);
shortDateFormat = intl.DateFormat.MEd(locale.languageCode);
mediumDateFormat = intl.DateFormat.MMMEd(locale.languageCode);
longDateFormat = intl.DateFormat.yMMMMEEEEd(locale.languageCode);
compactDateFormat = intl.DateFormat.MEd(locale.languageCode);
yearMonthFormat = intl.DateFormat.yMMMM(locale.languageCode);
shortMonthDayFormat = intl.DateFormat.Md(locale.languageCode);

return SynchronousFuture(MaterialLocalizationPtBR(
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat
));
Expand All @@ -66,14 +81,14 @@ class CupertinoLocalizationPtBR extends CupertinoLocalizationPt {

const CupertinoLocalizationPtBR({
String localeName = 'pt-BR',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat dayFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat singleDigitHourFormat,
@required intl.DateFormat singleDigitMinuteFormat,
@required intl.DateFormat doubleDigitMinuteFormat,
@required intl.DateFormat singleDigitSecondFormat,
@required intl.NumberFormat decimalFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat dayFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat singleDigitHourFormat,
required intl.DateFormat singleDigitMinuteFormat,
required intl.DateFormat doubleDigitMinuteFormat,
required intl.DateFormat singleDigitSecondFormat,
required intl.NumberFormat decimalFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
Expand Down Expand Up @@ -130,4 +145,4 @@ class CupertinoLocalizationPtBRDelegate extends LocalizationsDelegate<CupertinoL
}
@override
bool shouldReload(CupertinoLocalizationPtBRDelegate old) => false;
}
}
45 changes: 30 additions & 15 deletions lib/delegates/sv_se_localizations_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ class MaterialLocalizationSvSE extends MaterialLocalizationSv {

const MaterialLocalizationSvSE({
String localeName = 'sv-SE',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat longDateFormat,
@required intl.DateFormat yearMonthFormat,
@required intl.NumberFormat decimalFormat,
@required intl.NumberFormat twoDigitZeroPaddedFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat shortDateFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat longDateFormat,
required intl.DateFormat compactDateFormat,
required intl.DateFormat yearMonthFormat,
required intl.DateFormat shortMonthDayFormat,
required intl.NumberFormat decimalFormat,
required intl.NumberFormat twoDigitZeroPaddedFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat,
);
Expand All @@ -37,23 +43,32 @@ class MaterialLocalizationSvSEDelegate extends LocalizationsDelegate<MaterialLoc
@override
Future<MaterialLocalizationSvSE> load(Locale locale) {
intl.DateFormat fullYearFormat;
intl.DateFormat shortDateFormat;
intl.DateFormat mediumDateFormat;
intl.DateFormat longDateFormat;
intl.DateFormat compactDateFormat;
intl.DateFormat yearMonthFormat;
intl.DateFormat shortMonthDayFormat;
intl.NumberFormat decimalFormat;
intl.NumberFormat twoDigitZeroPaddedFormat;
decimalFormat = intl.NumberFormat.decimalPattern(locale.languageCode);
twoDigitZeroPaddedFormat = intl.NumberFormat('00', locale.languageCode);
fullYearFormat = intl.DateFormat.y(locale.languageCode);
shortDateFormat = intl.DateFormat.MEd(locale.languageCode);
mediumDateFormat = intl.DateFormat.MMMEd(locale.languageCode);
longDateFormat = intl.DateFormat.yMMMMEEEEd(locale.languageCode);
compactDateFormat = intl.DateFormat.MEd(locale.languageCode);
yearMonthFormat = intl.DateFormat.yMMMM(locale.languageCode);
shortMonthDayFormat = intl.DateFormat.Md(locale.languageCode);

return SynchronousFuture(MaterialLocalizationSvSE(
fullYearFormat: fullYearFormat,
shortDateFormat: shortDateFormat,
mediumDateFormat: mediumDateFormat,
longDateFormat: longDateFormat,
compactDateFormat: compactDateFormat,
yearMonthFormat: yearMonthFormat,
shortMonthDayFormat: shortMonthDayFormat,
decimalFormat: decimalFormat,
twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat
));
Expand All @@ -66,14 +81,14 @@ class CupertinoLocalizationSvSE extends CupertinoLocalizationSv {

const CupertinoLocalizationSvSE({
String localeName = 'sv-SE',
@required intl.DateFormat fullYearFormat,
@required intl.DateFormat dayFormat,
@required intl.DateFormat mediumDateFormat,
@required intl.DateFormat singleDigitHourFormat,
@required intl.DateFormat singleDigitMinuteFormat,
@required intl.DateFormat doubleDigitMinuteFormat,
@required intl.DateFormat singleDigitSecondFormat,
@required intl.NumberFormat decimalFormat,
required intl.DateFormat fullYearFormat,
required intl.DateFormat dayFormat,
required intl.DateFormat mediumDateFormat,
required intl.DateFormat singleDigitHourFormat,
required intl.DateFormat singleDigitMinuteFormat,
required intl.DateFormat doubleDigitMinuteFormat,
required intl.DateFormat singleDigitSecondFormat,
required intl.NumberFormat decimalFormat,
}) : super(
localeName: localeName,
fullYearFormat: fullYearFormat,
Expand Down Expand Up @@ -130,4 +145,4 @@ class CupertinoLocalizationSvSEDelegate extends LocalizationsDelegate<CupertinoL
}
@override
bool shouldReload(CupertinoLocalizationSvSEDelegate old) => false;
}
}
4 changes: 2 additions & 2 deletions lib/libs/pretty_count.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:Okuna/services/localization.dart';

String getPrettyCount(int value, LocalizationService localizationService) {
String postfix;
double finalValue;
late String postfix;
late double finalValue;

if (value < 0) {
throw 'Invalid value';
Expand Down
4 changes: 2 additions & 2 deletions lib/locale/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Map<String, LibraryLoader> _deferredLibraries = {
'tr': () => new Future.value(null),
};

MessageLookupByLibrary _findExact(String localeName) {
MessageLookupByLibrary? _findExact(String localeName) {
switch (localeName) {
case 'da':
return messages_da.messages;
Expand Down Expand Up @@ -95,7 +95,7 @@ bool _messagesExistFor(String locale) {
}
}

MessageLookupByLibrary _findGeneratedMessagesFor(String locale) {
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
onFailure: (_) => null);
if (actualLocale == null) return null;
Expand Down
26 changes: 13 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();

static void setLocale(BuildContext context, Locale newLocale) {
_MyAppState state = context.findAncestorStateOfType<_MyAppState>();
static void setLocale(BuildContext context, Locale? newLocale) {
_MyAppState? state = context.findAncestorStateOfType<_MyAppState>();

state.setState(() {
state.locale = newLocale;
state?.setState(() {
state.locale = newLocale ?? Locale('en', 'US');
});
}
}

class _MyAppState extends State<MyApp> {
Locale locale;
bool _needsBootstrap;
Locale? locale;
late bool _needsBootstrap;

static const MAX_NETWORK_IMAGE_CACHE_MB = 200;
static const MAX_NETWORK_IMAGE_CACHE_ENTRIES = 1000;
Expand Down Expand Up @@ -220,9 +220,9 @@ class _MyAppState extends State<MyApp> {
},
'/waitlist/subscribe_done_step': (BuildContext context) {
bootstrapOpenbookProviderInContext(context);
WaitlistSubscribeArguments args =
ModalRoute.of(context).settings.arguments;
return OBWaitlistSubscribeDoneStep(count: args.count);
WaitlistSubscribeArguments? args =
ModalRoute.of(context)?.settings.arguments as WaitlistSubscribeArguments?;
return OBWaitlistSubscribeDoneStep(count: args?.count ?? 0);
}
}),
),
Expand All @@ -232,7 +232,7 @@ class _MyAppState extends State<MyApp> {
void bootstrapOpenbookProviderInContext(BuildContext context) {
var openbookProvider = OpenbookProvider.of(context);
var localizationService = LocalizationService.of(context);
if (this.locale.languageCode !=
if (this.locale?.languageCode !=
localizationService.getLocale().languageCode) {
Future.delayed(Duration(milliseconds: 0), () {
MyApp.setLocale(context, this.locale);
Expand Down Expand Up @@ -260,11 +260,11 @@ Future<Null> main() async {
return;
}

SentryClient sentryClient =
app.openbookProviderKey.currentState.sentryClient;
SentryClient? sentryClient =
app.openbookProviderKey.currentState?.sentryClient;

try {
sentryClient.captureException(
sentryClient?.captureException(
error,
stackTrace: stackTrace,
);
Expand Down
Loading

0 comments on commit b0f8d93

Please sign in to comment.