onInit method
Describe the initialization process after the screen is displayed.
After this process is complete, the user is taken to the first screen.
画面表示後の初期化処理を記述します。
この処理が終わると最初の画面に遷移します。
Implementation
@override
FutureOr<void> onInit(BuildContext context) async {
final adapter = MasamuneModuleSimpleblogMasamuneAdapter.primary;
if (adapter.option.logoImage != null) {
await precacheImage(adapter.option.logoImage!.toImageProvider(), context);
}
await adapter.auth.tryRestoreAuth();
if (adapter.auth.isSignedIn) {
final user = UserModel.document(adapter.auth.userId).read(adapter.ref);
await user.load();
if (user.value == null) {
await user.save(UserModel(name: ml().guest));
}
}
}