We are trying to upgrade our flutter project to null safety migration using the following link https://dart.dev/null-safety/migration-guide.
dart pub outdated –mode=null-safety – Successful dart pub get – Successful Migrate your code by hand- https://dart.dev/null-safety/migration-guide#migrating-by-hand – Successful dart migrate – Successful
Facing error in the below code while trying to run the flutter command(Flutter run)
static Future<AppStrings> getAppText(String local) async {
var appTextBox = await Hive.openBox("appTextBox");
AppStrings appText = new AppStrings(
mainPageTitle: appTextBox.get('mainPageTitle'),
timeText: appTextBox.get('timeText'),
minutesText: appTextBox.get('minutesText'),
mainPageSubtitle: appTextBox.get('mainPageSubtitle'),
mainPageParagraph: appTextBox.get('mainPageParagraph'),
mainPageButton: appTextBox.get('mainPageButton'),
restartButton: appTextBox.get('restartButton'),
backButton: appTextBox.get('backButton'),
profileTitle: appTextBox.get('profileTitle'),
loadingPageSubtitle: appTextBox.get('loadingPageSubtitle'),
loadingPageBottomText: appTextBox.get('loadingPageBottomText'),
loadingPageTitle: appTextBox.get('loadingPageTitle'),
profileButton: appTextBox.get('profileButton'),
resultRestart: appTextBox.get('resultRestart'),
resultTitle: appTextBox.get('resultTitle'),
resultSwipe: appTextBox.get('resultSwipe'),
secondaryTitle: appTextBox.get('secondaryTitle'),
tretiaryProductTitle: appTextBox.get('tertiaryTitle'),
);
return appText;
}
Update:-
This is how we are calling this method from main.dart file
AppStrings? appText = (await DatabaseUtils.getAppText(local ?? ''));
return Data(
allProfiles: allProfiles,...........
)
2
Answers
change to
getAppText(String? local)
or
getAppText(String local ?? ”)
Try this:
And try leave the call like you showed above.