No Directionality widget found. InkWell widgets require a Directionality widget ancestor - dart

I am totally new to flutter and my first Steps already caused errors I cant solve by my own or searching this website..
I want to create a Button but get an Execption of missing Directionality as I understand. The only widget which needs the textDirection is the Text Widget, but it has ist, so whats wrong here? A Full Start also already tried several times incl. new emulator..
This is my code:
import 'package:flutter/material.dart';
void main(){
runApp(
new MyStatefullWidget()
) ;
}
class MyStatefullWidget extends StatefulWidget {
#override
_MyStatefullWidgetState createState() => _MyStatefullWidgetState();
}
class _MyStatefullWidgetState extends State<MyStatefullWidget> {
#override
Widget build(BuildContext context) {
return Container(
color:Colors.red,
child: Center(
child: RaisedButton(
child: Text("klick mich", textDirection: TextDirection.ltr),
onPressed: (){
print("Hi");
},
),
),
);
}
}
and this is the Error message:
I/flutter ( 4763): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 4763): The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
I/flutter ( 4763): dirty, state: _InkResponseState<InkResponse>#43345):
I/flutter ( 4763): No Directionality widget found.
I/flutter ( 4763): InkWell widgets require a Directionality widget ancestor.
I/flutter ( 4763): The specific widget that could not find a Directionality ancestor was:
I/flutter ( 4763): InkWell(gestures: [tap], clipped to BoxShape.rectangle)
I/flutter ( 4763): The ownership chain for the affected widget is:
I/flutter ( 4763): InkWell ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#64251 ink
I/flutter ( 4763): renderer] ← NotificationListener<LayoutChangedNotification> ← CustomPaint ← _ShapeBorderPaint ←
I/flutter ( 4763): PhysicalShape ← _MaterialInterior ← Material ← ⋯
I/flutter ( 4763): Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the
I/flutter ( 4763): top of your application widget tree. It determines the ambient reading direction and is used, for
I/flutter ( 4763): example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve
I/flutter ( 4763): EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.
I/flutter ( 4763):
I/flutter ( 4763): When the exception was thrown, this was the stack:
I/flutter ( 4763): #0 debugCheckHasDirectionality.<anonymous closure> (package:flutter/src/widgets/debug.dart:241:7)
I/flutter ( 4763): #1 debugCheckHasDirectionality (package:flutter/src/widgets/debug.dart:257:4)
I/flutter ( 4763): #2 InkResponse.debugCheckContext (package:flutter/src/material/ink_well.dart:376:12)
I/flutter ( 4763): #3 _InkResponseState.build (package:flutter/src/material/ink_well.dart:554:19)
I/flutter ( 4763): #4 StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter ( 4763): #5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 4763): #6 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #20 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #21 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #22 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #34 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #40 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #43 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #44 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #45 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #46 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #47 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #48 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #49 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #50 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #56 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #57 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #60 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #62 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #63 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #64 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #66 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #68 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #69 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #70 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #71 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #72 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #73 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #77 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #78 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #79 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #80 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #81 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #82 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #83 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #84 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #85 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #86 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #90 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #91 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #92 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #93 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #94 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #95 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #96 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #97 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #98 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #99 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #101 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
I/flutter ( 4763): #102 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
I/flutter ( 4763): #103 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:826:17)
I/flutter ( 4763): #104 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter ( 4763): #105 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
I/flutter ( 4763): #106 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
I/flutter ( 4763): #107 runApp (package:flutter/src/widgets/binding.dart:756:7)
I/flutter ( 4763): #108 main (package:flutter_app/main.dart:4:3)
I/flutter ( 4763): #109 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
I/flutter ( 4763): #110 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter ( 4763): ════════════════════════════════════════════════════════════════════════════════════════════════════

You have to add a MaterialApp widget before container, like this:
class _MyStatefullWidgetState extends State<MyStatefullWidget> {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Container(
color: Colors.red,
child: Center(
child: RaisedButton(
child: Text("klick mich", textDirection: TextDirection.ltr),
onPressed: () {
print("Hi");
},
),
),
),
);
}
}

I had this same error and to add more info, was able to resolve by looking at the error message, but the short of it is we can use MaterialApp or WidgetsApp at the top of the widget tree (as shown above):
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
dirty, state: _InkResponseState#1b61e):
No Directionality widget found.
InkWell widgets require a Directionality widget ancestor.
The specific widget that could not find a Directionality ancestor was:
InkWell
The ownership chain for the affected widget is: "InkWell ← DefaultTextStyle ←
AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#3bd76 ink renderer] ←
NotificationListener ← CustomPaint ← _ShapeBorderPaint ← PhysicalShape
← _MaterialInterior ← Material ← ⋯"
Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the
top of your application widget tree. It determines the ambient reading direction and is used, for
example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve
EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.

Related

Dynamically Updating TabController list at Runtime

I create a Pomodoro timer app use flutter. The home page has date TabController.
I record user first use the app date to a local JSON file. When the app starts checks the JSON file, and get the record. And calculate how many days between today, then I want to update tabcontroller.
The result is date correct, I set the initial index set the list.lenght - 1 but I set any number like 29,4,5,6, the underline is correct, but pageview is not right.
I think the problem is renewing tabController in setState, but I have tried many times it's not working.
Can someone help me see what went wrong? Thanks for the help.
I had code like this but not work.
Dynamically Updating TabControl Content at Runtime
void initState() {
super.initState();
jsonFileHelper = new JsonFileHelper();
myList.add(DateTime(today.year, today.month, today.day));
tabController = new TabController(
length: myList.length,
vsync: this,
);
jsonFileHelper.readToFile().then((res) {
firstDate = DateTime.fromMillisecondsSinceEpoch(res['firstDate']);
difference = DateTime(today.year, today.month, today.day)
.difference(firstDate)
.inDays;
setState(() {
myList.clear();
});
List<DateTime> tempList = new List();
for (int i = 0; i <= difference; i++) {
tempList.add(DateTime(today.year, today.month, today.day - i));
}
tempList.forEach((date) {
myList.insert(0, date);
});
setState(() {
tabController = new TabController(
length: myList.length,
vsync: this,
initialIndex: myList.length - 1);
tabController.addListener(() {
animationController.reverse();
});
});
}
});
}
// this is build tab function.
_buildTabs(List<DateTime> data) {
List<Widget> listWidget = new List();
data.forEach((date) {
var widget = Container(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Text(DateFormat('EEE').format(date)),
Text(
date.day.toString(),
style: TextStyle(
fontSize: 20.0,
color: Colors.black87,
fontWeight: FontWeight.bold,
),
),
],
),
),
);
listWidget.add(widget);
});
return listWidget;
}
I expect the output is shown last day, but the actual output is 2019-03-01(I set the first record is 2019-2-28).
I/flutter ( 8122): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8122): The following assertion was thrown building RawGestureDetector(state:
I/flutter ( 8122): RawGestureDetectorState#dc79e(gestures: [tap], behavior: opaque)):
I/flutter ( 8122): Multiple widgets used the same GlobalKey.
I/flutter ( 8122): The key [GlobalKey#82017] was used by multiple widgets. The parents of those widgets were:
I/flutter ( 8122): - Padding(padding: EdgeInsets(16.0, 0.0, 16.0, 0.0), dependencies: [Directionality], renderObject:
I/flutter ( 8122): RenderPadding#2875b NEEDS-LAYOUT NEEDS-PAINT DETACHED)
I/flutter ( 8122): - Padding(padding: EdgeInsets(16.0, 0.0, 16.0, 0.0), dependencies: [Directionality], renderObject:
I/flutter ( 8122): RenderPadding#2f066 NEEDS-LAYOUT NEEDS-PAINT)
I/flutter ( 8122): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter ( 8122):
I/flutter ( 8122): When the exception was thrown, this was the stack:
I/flutter ( 8122): #0 GlobalKey._debugReserveFor.<anonymous closure> (package:flutter/src/widgets/framework.dart:182:11)
I/flutter ( 8122): #1 GlobalKey._debugReserveFor (package:flutter/src/widgets/framework.dart:200:6)
I/flutter ( 8122): #2 Element.updateChild.<anonymous closure> (package:flutter/src/widgets/framework.dart:2730:13)
I/flutter ( 8122): #3 Element.updateChild (package:flutter/src/widgets/framework.dart:2733:6)
I/flutter ( 8122): #4 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 8122): #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter ( 8122): #6 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter ( 8122): #7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 8122): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter ( 8122): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter ( 8122): #10 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4659:32)
I/flutter ( 8122): #11 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #13 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #15 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #16 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #17 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #19 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #20 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #21 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #24 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #25 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #29 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #31 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #32 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #34 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #35 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #36 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #40 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #41 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #42 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #43 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #44 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #45 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #46 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #47 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #48 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #49 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #50 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #51 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #52 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #53 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #54 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #55 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #56 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #57 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #58 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #60 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #61 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #62 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #63 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #64 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #66 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #67 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #68 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #69 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #70 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #71 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #72 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #73 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #74 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #76 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #77 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #78 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #79 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #80 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #81 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #82 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #83 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #84 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #85 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #86 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #87 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #88 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #89 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #90 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #91 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #92 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #93 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #94 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #95 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #96 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #97 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #98 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #99 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #101 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #102 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #103 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #104 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #105 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #106 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #107 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #108 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #109 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #110 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #111 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #112 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #113 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #114 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #115 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #116 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #117 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #118 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #119 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #120 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #121 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #122 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #123 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #124 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #125 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #126 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #127 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #128 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #129 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #130 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #131 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #132 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #133 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #134 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #135 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): home page datetime: 2019-02-28T00:00:00.000
D/ ( 8122): HostConnection::get() New Host Connection established 0xebd99480, tid 8185
D/EGL_emulation( 8122): eglMakeCurrent: 0xf10dcf60: ver 3 0 (tinfo 0xebd832c0)
I/flutter ( 8122): #136 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #137 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #138 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #139 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #140 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #141 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #142 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #143 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #144 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #145 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #146 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #147 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #148 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #149 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #150 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #151 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #152 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #153 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #154 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #155 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #156 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #157 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #158 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #159 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #160 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #161 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter ( 8122): #162 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 8122): #163 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #164 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #165 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #166 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #167 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #168 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #169 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #170 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #171 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #172 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #173 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #174 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #175 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #176 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #177 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #178 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #179 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #180 StatelessElement.update (package:flutter/src/widgets/framework.dart:3796:5)
I/flutter ( 8122): #181 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #182 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 8122): #183 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #184 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #185 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #186 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #187 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #188 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #189 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #190 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #191 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #192 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #193 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #194 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #195 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #196 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #197 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #198 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 8122): #199 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #200 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #201 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #202 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 8122): #203 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter ( 8122): #204 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter ( 8122): #205 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter ( 8122): #206 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2273:33)
I/flutter ( 8122): #207 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter ( 8122): #208 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter ( 8122): #209 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter ( 8122): #210 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter ( 8122): #211 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:749:7)
I/flutter ( 8122): #220 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter ( 8122): #221 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter ( 8122): #222 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter ( 8122): (elided 8 frames from package dart:async)
I/flutter ( 8122): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 8122): Another exception was thrown: A RenderFlex overflowed by 99896 pixels on the bottom.
class _MyTabbedPageState extends State<MyTabbedPage> with SingleTickerProviderStateMixin
change to
class _MyTabbedPageState extends State<MyTabbedPage> with TickerProviderStateMixin
I change maxin
SingleTickerProviderStateMixin
to
TickerProviderStateMixin
it start working fine fo me as my requirement change length of tabs runtime
UPDATE
The solution I present here is not valid anymore. Please take a look in this answer
I had problems redefining the `TabController` length as well.
The solution was to create the TabController just once in initState and dispose it (only once too) - pretend that the TabController length is just a max length, if you think your app would have a maximum number of 100, use a fixed 100 then.

The getter 'length' was called on null

I trying to retrieve my data from API server and present it in my mobile application using flutter .. but i got error
The getter 'length' was called on null
Any advice plz ... thanks
my code is
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:core';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:json/add.dart';
void main() => runApp(MyApp());
Future<List> getData() async {
String url = 'http://192.168.0.55:4000/api/contacts';
http.Response response = await http.get(url);
return json.decode(response.body);
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
return MaterialApp(
routes: <String, WidgetBuilder>{
'/Add': (BuildContext context) => new Add(),
},
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
HomePageState createState() {
return new HomePageState();
}
}
class HomePageState extends State<HomePage> {
List data;
void getList() async {
this.data = (await getData());
print(data);
}
#override
void initState() {
getList();
}
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
centerTitle: true,
title: new Text("Chat"),
),
body: new Center(
child: new ListView.builder(
itemCount: data.length,
itemBuilder: (BuildContext context, int position) {
return new ListTile(
title: new Text('${data[position]['name']}'),
);
}),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.person_add),
onPressed: () {
Navigator.of(context).pushNamed('/Add');
}),
);
}
}
Output Console
Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 4,410ms.
I/flutter (10119): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (10119): The following NoSuchMethodError was thrown building HomePage(dirty, state: HomePageState#80635):
I/flutter (10119): The getter 'length' was called on null.
I/flutter (10119): Receiver: null
I/flutter (10119): Tried calling: length
I/flutter (10119):
I/flutter (10119): When the exception was thrown, this was the stack:
I/flutter (10119): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter (10119): #1 HomePageState.build (package:json/main.dart:59:29)
I/flutter (10119): #2 StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter (10119): #3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter (10119): #4 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #10 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #28 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #29 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #32 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #33 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #34 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #35 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #40 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #41 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #42 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #43 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #44 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #45 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #46 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #47 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #48 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #49 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #50 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #51 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #52 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #53 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #54 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #55 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #56 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #57 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #60 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #62 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #63 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #64 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #65 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #66 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #67 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #68 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #69 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #70 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #71 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #72 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #73 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #76 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #77 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #78 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #80 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #81 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #82 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #83 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #84 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #85 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #86 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #87 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #88 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #89 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #90 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #91 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #92 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #93 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #94 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #95 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #96 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #97 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #98 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (10119): #99 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #101 _TheatreElement.mount (package:flutter/src/widgets/overlay.dart:493:16)
I/flutter (10119): #102 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #103 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #104 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #105 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #106 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #107 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #108 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #109 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #110 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #111 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #112 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #113 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #114 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #115 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #116 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #117 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #118 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #119 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #120 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #121 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #122 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #123 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #124 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #125 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #126 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #127 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #128 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #163 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #164 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #165 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #166 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #167 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #168 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #169 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #170 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #171 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #172 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #173 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #174 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #175 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #176 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #177 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #178 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #179 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #180 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #181 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #182 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #183 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #184 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #185 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #186 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #187 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #202 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #203 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #204 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #205 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #206 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #207 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #208 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #209 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #210 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #211 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #212 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #213 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #214 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #215 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #216 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #217 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #218 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #219 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #220 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #221 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #222 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #223 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #224 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #225 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #226 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #227 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #228 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #229 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #230 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #231 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #232 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #233 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #234 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #235 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #236 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #237 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #238 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #239 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #240 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #241 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #242 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #243 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #244 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #245 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #246 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
I/flutter (10119): #247 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
I/flutter (10119): #248 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:826:17)
I/flutter (10119): #249 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter (10119): #250 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
I/flutter (10119): #251 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
I/flutter (10119): #252 runApp (package:flutter/src/widgets/binding.dart:756:7)
I/flutter (10119): #253 main (package:json/main.dart:8:16)
I/flutter (10119): #254 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
I/flutter (10119): #255 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (10119): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (10119): [{_id: 5c55e837b1dee7326c4ba39d, create_date: 2019-02-02T18:57:59.406Z, name: Tariq, gender: male, email: ta#gmail.com, phone: 07954622145, __v: 0}, {_id: 5c55e86cb1dee7326c4ba39e, create_date: 2019-02-02T18:58:52.346Z, name: He, gender: Female, email: h#gmail.com, phone: 075554622145, __v: 0}, {_id: 5c55e890b1dee7326c4ba39f, create_date: 2019-02-02T18:59:28.108Z, name: Sh, gender: Female, email: sh#gmail.com, phone: 075654622145, __v: 0}, {_id: 5c584f60af32d00dec0facae, create_date: 2019-02-04T14:42:40.036Z, name: Emad, gender: male, email: emad#gmail.com, __v: 0}, {_id: 5c585236af32d00dec0facaf, create_date: 2019-02-04T14:54:46.734Z, name: Fa, gender: Female, email: Fa#gmail.com, phone: 075654622145, __v: 0}, {_id: 5c58605bcf4f4c3008e50a04, create_date: 2019-02-04T15:55:07.696Z, name: Fa, gender: Female, email: f #gmail.com, phone: 075654622145, __v: 0}]
when i run the code i got the data in the console, but the UI for mobile APP . i get the error
output
You need to guard against the case when data == null
body: new Center(
child: data == null ? Container() : new ListView.builder(
itemCount: data.length,
itemBuilder: (BuildContext context, int position) {
return new ListTile(
title: new Text('${data[position]['name']}'),
);
}),
),
The reason behind is If you are using a List and trying to get it's length while the list is null.
In order to remove the exception is to initialize the List data (in the above code) with some values (Before getting the required values).
What I did was just initialized the list with an empty array. like,
List _elements = [];
Comments please.
Answer by ABHIMANGAL MS was perfect for me.
We made a list data at the top of our page like:
list data;
This was null obv. We then ran json under it to get our data from an api and populate data with that info.
However the page would first load data while empty then make the api call.
Making data: list data = []; removed the error it would throw up for a second before loading the json data. so thank you !!!
For my own future reference when receiving this error during http POST requests, Flutter doesn't like sending null values in the body of the request. I was working with an API call that had a null requirement in the request - I simply ignored this and only sent the parameters that were non-null

Using Targetplatform causes layout problem

I am trying to check if user is on Iphone or Android
I am following this post to check
How do you detect the host platform from Dart code?
in my initState i have added the following check
typeOfDevice = Theme.of(context).platform == TargetPlatform.iOS
? "1"
: "2";
but whenever i tried to use that i get following error
I/flutter (22330): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (22330): The following assertion was thrown building MediaQuery(MediaQueryData(size: Size(360.0, 640.0),
I/flutter (22330): devicePixelRatio: 2.0, textScaleFactor: 1.0, padding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets:
I/flutter (22330): EdgeInsets.zero, alwaysUse24HourFormat: false, accessibleNavigation: falsedisableAnimations:
I/flutter (22330): falseinvertColors: falseboldText: false)):
I/flutter (22330): inheritFromWidgetOfExactType(_InheritedTheme) or inheritFromElement() was called before
I/flutter (22330): _EnterOtpLoginState.initState() completed.
I/flutter (22330): When an inherited widget changes, for example if the value of Theme.of() changes, its dependent
I/flutter (22330): widgets are rebuilt. If the dependent widget's reference to the inherited widget is in a constructor
I/flutter (22330): or an initState() method, then the rebuilt dependent widget will not reflect the changes in the
I/flutter (22330): inherited widget.
I/flutter (22330): Typically references to to inherited widgets should occur in widget build() methods. Alternatively,
I/flutter (22330): initialization based on inherited widgets can be placed in the didChangeDependencies method, which
I/flutter (22330): is called after initState and whenever the dependencies change thereafter.
I/flutter (22330): When the exception was thrown, this was the stack:
I/flutter (22330): #0 StatefulElement.inheritFromElement.<anonymous closure> (package:flutter/src/widgets/framework.dart:3920:9)
I/flutter (22330): #1 StatefulElement.inheritFromElement (package:flutter/src/widgets/framework.dart:3953:6)
I/flutter (22330): #2 Element.inheritFromWidgetOfExactType (package:flutter/src/widgets/framework.dart:3274:14)
I/flutter (22330): #3 Theme.of (package:flutter/src/material/theme.dart:127:52)
I/flutter (22330): #4 _EnterOtpLoginState.initState (package:dice_clutter/screens/otp_login/otp_login.dart:126:26)
I/flutter (22330): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3830:58)
I/flutter (22330): #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #8 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #10 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #19 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #20 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #21 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #22 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #23 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
I/flutter (22330): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #25 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #35 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #36 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #37 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #38 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #45 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #47 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #48 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #49 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #50 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #51 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #52 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #53 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #54 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #55 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #56 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #57 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #60 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #61 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #62 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #63 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #64 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #65 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #66 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #67 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #68 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #69 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #70 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #71 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #72 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #73 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #74 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #75 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #76 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #77 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #78 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #79 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #80 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #81 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #82 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #83 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #84 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #85 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #86 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #87 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #88 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #89 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #90 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #91 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #92 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #93 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #94 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #95 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #96 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #97 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #98 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #99 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #100 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #101 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #102 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #103 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #104 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #105 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #106 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #107 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #108 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #109 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #110 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #111 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #112 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #113 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #114 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #115 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #116 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #117 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #118 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #119 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #120 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #121 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #122 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #123 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #124 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #125 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #126 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #127 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #128 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #129 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #130 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #131 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #132 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #133 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #134 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #135 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #136 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #137 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #138 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #139 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #140 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #141 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #142 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #143 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #144 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #145 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #146 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #147 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #148 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #149 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #150 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #151 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #152 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #153 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #154 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #155 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #156 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #157 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #158 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #159 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #160 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #161 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #162 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #163 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #164 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #165 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #166 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #167 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #168 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #169 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #170 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #171 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #172 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #173 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #174 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #175 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #176 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #177 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #178 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #179 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #180 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #181 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #182 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #183 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #184 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #185 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #186 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #187 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #188 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #189 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #190 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #191 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #192 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #193 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #194 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #195 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4643:32)
I/flutter (22330): #196 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4975:17)
I/flutter (22330): #197 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #198 _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
I/flutter (22330): #199 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #200 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #201 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #202 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter (22330): #203 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #204 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #205 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #206 ProxyElement.update (package:flutter/src/widgets/framework.dart:3990:5)
I/flutter (22330): #207 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #208 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #209 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #210 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #211 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #212 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter (22330): #213 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #214 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #215 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #216 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #217 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #218 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #219 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #220 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter (22330): #221 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter (22330): #222 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (22330): #223 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (22330): #224 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (22330): #225 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (22330): #226 _invoke (dart:ui/hooks.dart:154:13)
I/flutter (22330): #227 _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (22330): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (22330): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child:
I/flutter (22330): Another exception was thrown: inheritFromWidgetOfExactType(_InheritedTheme) or inheritFromElement() was called before _EnterOtpLoginState.initState() completed.
I/flutter (22330): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following children:
when i comment that line of code the app runs fine
This issue happens because you're trying to obtain an Inheritedwidget from initState. Which is purposefully not possible
Instead use didChangeDependencies:
didChangeDependencies() {
typeOfDevice = Theme.of(context).platform == TargetPlatform.iOS
}

How to use Expanded in stepper when using columns

Here is a relatable stack overflow question .
Flutter : Step widget can not hold Expanded
If one reads the comments #derek-lakin, concludes that one should use a column inside a stepper, as stepper is scrollable. I am doing the exact same thing, however i face an issue that column makes the Text widget to take only the required space, and not the entire screen width. I can notice this if i wrap the Text widget with a Material widget and apply elevation or color.
I tried to wrap Expanded widget around my Column of widgets to fix this. However, i get render errors.
Can someone let me know, how can I build a stepper, with a step that consists of hierarchy as Expanded(Column(children:List[Widgets])).
I am able to build a stepper using only column, but i was thinking of using expanded to correct the inappropriate sizing issues in column
stepWidget = Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets, //List of my widgets
));
This gives the following error:
I/flutter (19635): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (19635): The following assertion was thrown building NotificationListener<KeepAliveNotification>:
I/flutter (19635): Incorrect use of ParentDataWidget.
I/flutter (19635): Expanded widgets must be placed directly inside Flex widgets.
I/flutter (19635): Expanded(no depth, flex: 2, dirty) has a Flex ancestor, but there are other widgets between them:
I/flutter (19635): - RepaintBoundary-[<0>]
I/flutter (19635): - IndexedSemantics(index: 0)
I/flutter (19635): - KeepAlive(keepAlive: false)
I/flutter (19635): - SliverList(delegate: SliverChildListDelegate#de272(estimated child count: 1))
I/flutter (19635): - SliverPadding(padding: EdgeInsets.zero)
I/flutter (19635): - ShrinkWrappingViewport(axisDirection: down, offset: ScrollPositionWithSingleContext#83fdf(offset:
I/flutter (19635): 0.0, range: null..null, viewport: null, ScrollableState, ClampingScrollPhysics,
I/flutter (19635): IdleScrollActivity#b00f3, ScrollDirection.idle))
I/flutter (19635): - IgnorePointer-[GlobalKey#88af5](ignoring: false, ignoringSemantics: false)
I/flutter (19635): - Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter (19635): hintOverrides: null)
I/flutter (19635): - Listener(listeners: [down], behavior: opaque)
I/flutter (19635): - _GestureSemantics
I/flutter (19635): - _ScrollSemantics-[GlobalKey#81c78]
I/flutter (19635): - RepaintBoundary
I/flutter (19635): - CustomPaint
I/flutter (19635): - RepaintBoundary
I/flutter (19635): - Expanded(flex: 1) (this is a different Expanded than the one with the problem)
I/flutter (19635): These widgets cannot come between a Expanded and its Flex.
I/flutter (19635): The ownership chain for the parent of the offending Expanded was:
I/flutter (19635): RepaintBoundary-[<0>] ← IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive
I/flutter (19635): ← AutomaticKeepAlive ← SliverList ← MediaQuery ← SliverPadding ← ShrinkWrappingViewport ←
I/flutter (19635): _ScrollableScope ← ⋯
I/flutter (19635):
I/flutter (19635): When the exception was thrown, this was the stack:
I/flutter (19635): #0 ParentDataElement.mount.<anonymous closure> (package:flutter/src/widgets/framework.dart:4015:7)
I/flutter (19635): #1 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4024:6)
I/flutter (19635): #2 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #3 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #4 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4838:14)
I/flutter (19635): #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #6 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4838:14)
I/flutter (19635): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #20 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4025:11)
I/flutter (19635): #21 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #24 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #25 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #26 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3826:11)
I/flutter (19635): #27 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #29 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #30 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1012:36)
I/flutter (19635): #31 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:997:20)
I/flutter (19635): #32 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter (19635): #33 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:990:11)
I/flutter (19635): #34 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:256:23)
I/flutter (19635): #35 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1730:58)
I/flutter (19635): #36 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:799:15)
I/flutter (19635): #37 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1730:13)
I/flutter (19635): #38 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:245:5)
I/flutter (19635): #39 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:323:5)
I/flutter (19635): #40 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:78:12)
I/flutter (19635): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #42 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
I/flutter (19635): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #44 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:405:13)
I/flutter (19635): #45 RenderShrinkWrappingViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1645:12)
I/flutter (19635): #46 RenderShrinkWrappingViewport.performLayout (package:flutter/src/rendering/viewport.dart:1608:20)
I/flutter (19635): #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #52 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #54 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #55 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #57 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #62 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #63 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #64 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:798:17)
I/flutter (19635): #65 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #66 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (19635): #67 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (19635): #68 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (19635): #69 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (19635): #70 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (19635): #71 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (19635): #72 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (19635): #73 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (19635): #74 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (19635): #75 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (19635): #76 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (19635): #77 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (19635): #78 _invoke (dart:ui/hooks.dart:151:13)
I/flutter (19635): #79 _drawFrame (dart:ui/hooks.dart:140:3)
I/flutter (19635): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (19635): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 217 pos 16: 'indexOf(child) > index': is not true.
I/flutter (19635): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 217 pos 16: 'indexOf(child) > index': is not true.
I/flutter (19635): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 2270 pos 20: '_debugCurrentBuildTarget == context': is not true.
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderShrinkWrappingViewport#44117 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#7c8dd relayoutBoundary=up9 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#f736b relayoutBoundary=up8 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#3760f relayoutBoundary=up7 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#860e2 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#b1734 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#d9292 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#44461 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#4425c relayoutBoundary=up2 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderFlex#e5d03 relayoutBoundary=up1 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
As per the error: Expanded widgets must be placed directly inside Flex widgets.
Why?
As per docs:
An Expanded widget must be a descendant of a Row, Column, or Flex, and the path from the Expanded widget to its enclosing Row, Column, or Flex must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).
You can place Expanded widget inside Column and put that Column inside your Step widget, but you can not place Expanded directly inside your Step widget's content.
I'll update my answer once you'll provide the full code to provide you with the solution.
Till then, here's what you can do.
Container(
width: double.infinity, //To make it use as much space as it wants
height: whateverHeightYouWantTo,
child: Column(
children: <Widget>[
Expanded(child: Widget()) //You'll probably won't need Expanded by now.
]
)
)

Error: '_elements.contains(element)': is not true

I am seeing this error '_elements.contains(element)': is not true.for the past two days in my flutter project, this was working absolutely fine since the beginning. I am sorry to say this but I have no clue regarding this error but i think i am missing something which is causing this error. Also, when I hot reload the same page the layout is populated, but throws the exceptions.
Intermittently this was also showing Duplicate GlobalKeys() detected, but this wasn't the case in the beginning.
Please can someone help me if they stumbled upon these errors before. I couldn't really write an example to reproduce the same problem. Many thanks.
I have given the error details as follows:
Performing hot reload...
I/flutter (22248): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY
╞═══════════════════════════════════════════════════════════
I/flutter (22248): The following assertion was thrown building
TickerMode(mode: disabled):
I/flutter (22248): 'package:flutter/src/widgets/framework.dart': Failed
assertion: line 1766 pos 12:
I/flutter (22248): '_elements.contains(element)': is not true.
I/flutter (22248):
I/flutter (22248): Either the assertion indicates an error in the framework
itself, or we should provide substantially
I/flutter (22248): more information in this error message to help you
determine and fix the underlying cause.
I/flutter (22248): In either case, please report this assertion by filing a
bug on GitHub:
I/flutter (22248): https://github.com/flutter/flutter/issues/new
I/flutter (22248):
I/flutter (22248): When the exception was thrown, this was the stack:
I/flutter (22248): #2 _InactiveElements.remove
(package:flutter/src/widgets/framework.dart:1766:12)
I/flutter (22248): #3 Element._retakeInactiveElement
(package:flutter/src/widgets/framework.dart:2850:29)
I/flutter (22248): #4 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:2873:32)
I/flutter (22248): #5 Element.updateChild
(package:flutter/src/widgets/framework.dart:2688:12)
I/flutter (22248): #6 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #7 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #8 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #9 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #10 RenderObjectElement.updateChildren
(package:flutter/src/widgets/framework.dart:4262:32)
I/flutter (22248): #11 _TheatreElement.update
(package:flutter/src/widgets/overlay.dart:508:17)
I/flutter (22248): #12 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #13 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #14 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #15 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #16 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #17 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #18 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #19 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #20 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #21 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #22 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #23 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #24 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #25 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #26 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #27 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #28 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #29 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #30 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #31 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #32 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #33 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #34 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #35 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #36 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #37 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #38 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #39 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #40 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #41 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #42 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #43 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #44 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #45 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #46 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #47 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #48 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #49 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #50 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #51 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #52 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #53 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #54 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #55 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #56 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #57 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #58 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #59 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #60 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #61 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #62 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #63 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #64 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #65 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #66 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #67 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #68 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #69 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #70 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #71 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #72 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #73 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #74 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #75 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #76 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #77 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #78 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #79 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #80 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #81 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #82 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #83 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #84 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #85 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #86 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #87 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #88 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #89 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #90 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #91 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #92 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #93 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #94 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #95 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #96 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #97 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #98 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #99 BuildOwner.buildScope
(package:flutter/src/widgets/framework.dart:2246:33)
I/flutter (22248): #100
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding&WidgetsBinding.drawFrame
(package:flutter/src/widgets/binding.dart:580:20)
I/flutter (22248): #101
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding._handlePersistentFrameCallback
(package:flutter/src/rendering/binding.dart:200:5)
I/flutter (22248): #102
BindingBase&SchedulerBinding._invokeFrameCallback
(package:flutter/src/scheduler/binding.dart:713:15)
I/flutter (22248): #103 BindingBase&SchedulerBinding.handleDrawFrame
(package:flutter/src/scheduler/binding.dart:649:9)
I/flutter (22248): #104
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding.scheduleWarmUpFrame.<anonymous closure>
(package:flutter/src/rendering/binding.dart:286:20)
I/flutter (22248): #106 _Timer._runTimers (dart:isolate-
patch/dart:isolate/timer_impl.dart:367)
I/flutter (22248): #107 _Timer._handleMessage (dart:isolate-
patch/dart:isolate/timer_impl.dart:401)
I/flutter (22248): #108 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
I/flutter (22248): (elided 3 frames from class _AssertionError and
package dart:async-patch)
I/flutter (22248):
══════════════════════════════════════════════════════════════════════════
══════════════════════════
Reloaded 0 of 492 libraries in 823ms.
I have included a sample example of what i am trying to do in my application.
main.dart
import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart';
import 'package:untitled3/secondwidget.dart';
void main() {
runApp(
new Example(),
);
}
class Example extends StatefulWidget {
#override
_ExampleState createState() => new _ExampleState();
}
class _ExampleState extends State<Example> {
int noOfBranches;
#override
void initState() {
super.initState();
getCount();
}
void getCount() {
print('list builder count is ${noOfBranches}');
}
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
return new MaterialApp(
home: new Scaffold(
body: new ListView.builder(
itemCount: noOfBranches,
itemBuilder: (BuildContext context, int index) {
return new Card(
child: new FlatButton(
onPressed: (() {
Navigator.push(
context,
new MaterialPageRoute(
builder: (_) => new SecondWidget()));
}),
child: new Text('Next Widget')),
);
}),
),
);
}
}
secondwidget.dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class SecondWidget extends StatefulWidget {
#override
_SecondWidgetState createState() => new _SecondWidgetState();
}
class _SecondWidgetState extends State<SecondWidget> {
#override
Widget build(BuildContext context) {
return new Container(
child: new Text('Second Widget'),
);
}
}
I don't see the error in my application if setState() declare as given in the example main.dart file inside the
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
.....
}
but I only see this error if I declare the setState() inside the getCount() function.
I am not so sure why this is the case.
I am actually stuck on this error for two days and any help would be greatly appreciated.
Many Thanks,
Mahi
I think I kinda solved the error by declaring the setState() inside the
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
print('noof branches inside widget build = $noOfBranches');
.....
}
Now the app is running absolutely fine without any problems.
But, I would be grateful if there are any more suggestions as I am new to programming and would be very very happy to learn more.
The only problem was the setState() was modifying the context and when clicked on the button to call another widget it was throwing up with this error message.
Many Thanks,
Mahi.
Why don't you set your noOfBranches variable not in the initState method?
#override
void initState() {
super.initState();
noOfBranches = 2;
}

Resources