質問編集履歴

2

追記を削除

2021/07/11 02:49

投稿

Gento
Gento

スコア77

test CHANGED
File without changes
test CHANGED
@@ -318,7 +318,11 @@
318
318
 
319
319
  final movie = model.myPageMovie;
320
320
 
321
+ return movie == null
322
+
323
+ ? Center(child: CircularProgressIndicator())
324
+
321
- return Form(
325
+ : Form(
322
326
 
323
327
  key: formKey,
324
328
 
@@ -450,34 +454,6 @@
450
454
 
451
455
 
452
456
 
453
- ##謎のwidgetsエラー
454
-
455
-
456
-
457
- ```console
458
-
459
- ════════ Exception caught by widgets library ═══════════════════════════════════
460
-
461
- The getter 'pointText1' was called on null.
462
-
463
- Receiver: null
464
-
465
- Tried calling: pointText1
466
-
467
- The relevant error-causing widget was
468
-
469
- Consumer<MyPageMovieProvider>
470
-
471
- lib/…/mypage/mypage_movie_form.dart:201
472
-
473
- ```
474
-
475
-
476
-
477
- Formの画面を開くたびにこのエラーが発生します。全く理由がわかりません。。。
478
-
479
-
480
-
481
457
  #試したこと
482
458
 
483
459
  `mypage_movie_provider.dart`で定義されている`point1Text`に初期値を入れてみました。
@@ -546,62 +522,6 @@
546
522
 
547
523
 
548
524
 
549
- #追記
550
-
551
-
552
-
553
- ```dart:mypage_movie_form.dart
554
-
555
- @override
556
-
557
- Widget build(BuildContext context) {
558
-
559
- return ChangeNotifierProvider<MyPageMovieProvider>.value(
560
-
561
- value: MyPageMovieProvider()..fetchMyMovies(id),
562
-
563
- child: Consumer<MyPageMovieProvider>(
564
-
565
- builder: (context, model, child) {
566
-
567
- final movie = model.myPageMovie;
568
-
569
- return movie == null
570
-
571
- ? Center(child: CircularProgressIndicator())
572
-
573
- : Form(
574
-
575
- key: formKey,
576
-
577
- ```
578
-
579
-
580
-
581
- `mypage_movie_form.dart`で`model.myPageMovie`のnullの対応を追加すると、下記のエラーは解消されました!
582
-
583
-
584
-
585
- ```console
586
-
587
- ════════ Exception caught by widgets library ═══════════════════════════════════
588
-
589
- The getter 'pointText1' was called on null.
590
-
591
- Receiver: null
592
-
593
- Tried calling: pointText1
594
-
595
- The relevant error-causing widget was
596
-
597
- Consumer<MyPageMovieProvider>
598
-
599
- lib/…/mypage/mypage_movie_form.dart:201
600
-
601
- ```
602
-
603
-
604
-
605
525
  #最後に
606
526
 
607
527
  **Providerが難しくてあまり理解できていません。。どなたかご教授いただけると幸いです!**

1

追記を追加

2021/07/11 02:49

投稿

Gento
Gento

スコア77

test CHANGED
File without changes
test CHANGED
@@ -546,6 +546,62 @@
546
546
 
547
547
 
548
548
 
549
+ #追記
550
+
551
+
552
+
553
+ ```dart:mypage_movie_form.dart
554
+
555
+ @override
556
+
557
+ Widget build(BuildContext context) {
558
+
559
+ return ChangeNotifierProvider<MyPageMovieProvider>.value(
560
+
561
+ value: MyPageMovieProvider()..fetchMyMovies(id),
562
+
563
+ child: Consumer<MyPageMovieProvider>(
564
+
565
+ builder: (context, model, child) {
566
+
567
+ final movie = model.myPageMovie;
568
+
569
+ return movie == null
570
+
571
+ ? Center(child: CircularProgressIndicator())
572
+
573
+ : Form(
574
+
575
+ key: formKey,
576
+
577
+ ```
578
+
579
+
580
+
581
+ `mypage_movie_form.dart`で`model.myPageMovie`のnullの対応を追加すると、下記のエラーは解消されました!
582
+
583
+
584
+
585
+ ```console
586
+
587
+ ════════ Exception caught by widgets library ═══════════════════════════════════
588
+
589
+ The getter 'pointText1' was called on null.
590
+
591
+ Receiver: null
592
+
593
+ Tried calling: pointText1
594
+
595
+ The relevant error-causing widget was
596
+
597
+ Consumer<MyPageMovieProvider>
598
+
599
+ lib/…/mypage/mypage_movie_form.dart:201
600
+
601
+ ```
602
+
603
+
604
+
549
605
  #最後に
550
606
 
551
607
  **Providerが難しくてあまり理解できていません。。どなたかご教授いただけると幸いです!**