我们正在尝试使用以下链接https://dart.dev/null-safety/migration-guide将flutter项目升级到null安全迁移。
dart pub outdated --mode=null-safety - Successful dart pub get - Successful手动迁移代码-https://dart.dev/null-safety/migration-guide#migrating-by-hand- Successful dart migrate - Successful
尝试运行Flutter命令时,以下代码中出现错误(Flutter运行)
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;
}
更新:-
这就是我们如何从main.dart文件调用这个方法
AppStrings? appText = (await DatabaseUtils.getAppText(local ?? ''));
return Data(
allProfiles: allProfiles,...........
)
2条答案
按热度按时间vmjh9lq91#
更改为getAppText(String?local)或getAppText(String local??'')
o8x7eapl2#
试试这个:
并尝试像上面显示的那样离开呼叫。