回答編集履歴
1
誤字の修正
answer
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
dependOnInheritedWidgetOfExactType<_LocalizationsScope>() or dependOnInheritedElement() was called before _WorkFormState.initState() completed.
|
16
16
|
```
|
17
17
|
解決方法:
|
18
|
-
didChangeDependenciesを使用して、initState完了後に処理を実行する。
|
18
|
+
①didChangeDependenciesを使用して、initState完了後に処理を実行する。
|
19
19
|
```dart
|
20
20
|
@override
|
21
21
|
void didChangeDependencies() {
|
@@ -23,7 +23,7 @@
|
|
23
23
|
_startTimeInputController = new TextEditingController(widget.workData!.startTime.format(context));
|
24
24
|
}
|
25
25
|
```
|
26
|
-
initState内でFutureを使用して無理やりinitStateが完了するのを待つ
|
26
|
+
②initState内でFutureを使用して無理やりinitStateが完了するのを待つ
|
27
27
|
```dart
|
28
28
|
@override
|
29
29
|
void initState() {
|
@@ -33,5 +33,5 @@
|
|
33
33
|
});
|
34
34
|
}
|
35
35
|
```
|
36
|
-
参
|
36
|
+
参照元でも書いていましたが、①のdidChangeDependenciesを使用したほうが良さげな気がします。
|
37
37
|
参照:[Unhandled Exception: inheritFromWidgetOfExactType(_LocalizationsScope) or inheritFromElement() was called before _ScreenState.initState() completed](https://stackoverflow.com/questions/56395081/unhandled-exception-inheritfromwidgetofexacttype-localizationsscope-or-inheri)
|