I have been using TabBar() in my flutter app, and it was working unless I found it my TabBarView() messes up when the screen size changes.
After following this question I have found out the solution to my problem is Expanded() for TabBarView(). I have tried my level best but all I'm getting is a lot of error regarding rendering my data.
⡿flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
⣟flutter: When a column is in a parent that does not provide a finite height constraint, for example if it is
flutter: in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
flutter: flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
flutter: space in the vertical direction.
flutter: These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
flutter: cannot simultaneously expand to fit its parent.
flutter: Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
flutter: children (using Flexible rather than Expanded). This will allow the flexible children to size
flutter: themselves to less than the infinite remaining space they would otherwise be forced to take, and
flutter: then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
flutter: constraints provided by the parent.
flutter: If this message did not help you determine the problem, consider using debugDumpRenderTree():
flutter: https://flutter.dev/debugging/#rendering-layer
flutter: http://docs.flutter.io/flutter/rendering/debugDumpRenderTree.html
flutter: The affected RenderFlex is:
flutter: RenderFlex#bc077 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT(creator: Column ← TabWidget ← Column ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#4f100 ink renderer] ← NotificationListener<LayoutChangedNotification> ← PhysicalModel ← ⋯, parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size), constraints: BoxConstraints(w=375.0, 0.0<=h<=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: min, crossAxisAlignment: start, textDirection: ltr, verticalDirection: down)
flutter: The creator information is set to:
flutter: Column ← TabWidget ← Column ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ←
flutter: CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
flutter: _InkFeatures-[GlobalKey#4f100 ink renderer] ← NotificationListener<LayoutChangedNotification> ←
flutter: PhysicalModel ← ⋯
flutter: The nearest ancestor providing an unbounded width constraint is: RenderFlex#0807f relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT:
flutter: creator: Column ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ←
flutter: AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#4f100 ink
flutter: renderer] ← NotificationListener<LayoutChangedNotification> ← PhysicalModel ←
flutter: AnimatedPhysicalModel ← Material ← ⋯
flutter: parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
flutter: constraints: BoxConstraints(0.0<=w<=375.0, 0.0<=h<=591.0)
flutter: size: MISSING
flutter: direction: vertical
flutter: mainAxisAlignment: start
flutter: mainAxisSize: min
flutter: crossAxisAlignment: stretch
flutter: verticalDirection: down
flutter: See also: https://flutter.dev/layout/
flutter: If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RenderFlex.performLayout.<anonymous closure> (package:flutter/src/rendering/flex.dart:691:11)
flutter: #1 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:717:10)
flutter: #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #3 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:743:15)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #5 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
flutter: #6 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:443:7)
flutter: #7 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
flutter: #8 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
flutter: #9 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #10 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #11 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #12 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #13 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1214:11)
flutter: #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #15 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #21 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #23 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #34 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3067:13)
flutter: #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #36 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #38 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #40 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
flutter: #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1620:7)
flutter: #50 RenderView.performLayout (package:flutter/src/rendering/view.dart:151:13)
flutter: #51 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1497:7)
flutter: #52 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
flutter: #53 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:346:19)
flutter: #54 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
flutter: #55 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
flutter: #56 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
flutter: #57 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
flutter: #58 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:773:7)
flutter: #60 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
flutter: #61 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
flutter: #62 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async-patch)
flutter:
flutter: The following RenderObject was being processed when the exception was fired: RenderFlex#bc077 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT:
flutter: creator: Column ← TabWidget ← Column ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ←
flutter: CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
flutter: _InkFeatures-[GlobalKey#4f100 ink renderer] ← NotificationListener<LayoutChangedNotification> ←
flutter: PhysicalModel ← ⋯
⣯flutter: parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
flutter: constraints: BoxConstraints(w=375.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: direction: vertical
flutter: mainAxisAlignment: start
flutter: mainAxisSize: min
flutter: crossAxisAlignment: start
flutter: textDirection: ltr
flutter: verticalDirection: down
flutter: This This RenderObject had the following descendants (showing up to depth 5):
flutter: child 1: RenderPadding#ec776 relayoutBoundary=up3 NEEDS-PAINT
flutter: child: RenderDecoratedBox#82c7d relayoutBoundary=up4 NEEDS-PAINT
flutter: child: RenderPadding#47def relayoutBoundary=up5 NEEDS-PAINT
flutter: child: RenderCustomPaint#d3174 relayoutBoundary=up6 NEEDS-PAINT
flutter: child: _TabLabelBarRenderer#1dbbb relayoutBoundary=up7 NEEDS-PAINT
flutter: child 2: _RenderScrollSemantics#ab273 NEEDS-LAYOUT NEEDS-PAINT
flutter: child: RenderPointerListener#85f41 NEEDS-LAYOUT NEEDS-PAINT
flutter: child: RenderSemanticsGestureHandler#dfb17 NEEDS-LAYOUT NEEDS-PAINT
flutter: child: RenderPointerListener#36472 NEEDS-LAYOUT NEEDS-PAINT
flutter: child: RenderSemanticsAnnotations#0d0f0 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#bc077 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#0807f relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: NoSuchMethodError: The method '>' was called on null.
Now to give you an insight of what I have been doing is that, I have a widget class in which I have defined my TabBar and I'm using this in different places.
This is my widget for TabBar class:
#override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(left: 16.0, right: 16.0),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.0),
border: Border(bottom: BorderSide(color: Colors.grey, width: 0.5))),
child: TabBar(
unselectedLabelColor: Colors.grey,
unselectedLabelStyle: TextStyle().copyWith(fontSize: 16.0, fontWeight: FontWeight.normal),
labelColor: Color.fromRGBO(253, 92, 99, 1),
labelStyle: TextStyle().copyWith(fontSize: 16.0, fontWeight: FontWeight.bold),
indicatorColor: Color.fromRGBO(253, 92, 99, 1),
indicatorWeight: widget.indicatorWeight,
controller: _controller,
tabs: [
new Tab(
child: Padding(
padding: EdgeInsets.only(top: 18.0),
child: Text(widget.childOneHeader, style: TextStyle(fontSize: 15.0)),
)
),
new Tab(
child: Padding(
padding: EdgeInsets.only(top: 18.0),
child: Text(widget.childTwoHeader, style: TextStyle(fontSize: 15.0)),
)
),
new Tab(
child: Padding(
padding: EdgeInsets.only(top: 18.0),
child: Text(widget.childThreeHeader, style: TextStyle(fontSize: 15.0)),
)
)
]
)
),
Expanded(
//height: widget.layoutHeight,
child: new TabBarView(
controller: _controller,
children: <Widget>[
widget.childOne,
widget.childTwo,
widget.childThree
],
)
)
]
);
The data with widget. is coming from it's constructor.
Now I have been using this in my page which has ListView() for my TabBarView() children, so I'm passing it from them only.
Class Using TabBar Code:
body: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text('Heading'),
Container(),
TabWidget(
indicatorWeight: 1.0,
childOneHeader: 'Title 1',
childTwoHeader: 'Title 2',
childThreeHeader: 'Title 3',
childOne: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: this.isDataNull ?
[Container(
child: errorWidget,
)]
: this.getOffersWidgets()
),
childTwo: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: this.isDataNull ?
[Container(
child: errorWidget,
)]
: this.getBarWidgets()
),
childThree: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: this.isDataNull ?
[Container(
child: errorWidget,
)]
: this.getEventWidget()
)
)
]
);
I have tried my level best couldn't get it to work. All I'm getting is a blank page nothing else. Please help me with this. Thanks :)
SOLUTION:
Since I have found a way out, so I think my friends who will see this question in the future will get benefited from the question as well.
This is the link to the answer by the way if you want to take a peek of that : Solution to my problem
In the class using tabbarcode, wrap the TabWidget inside Expanded() and rest will be the same, and your job is done.
body: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text('Heading'),
Container(),
Expanded(
child: TabWidget(//your content goes here)
)
Special thanks to MFARKAN.
Please note, never ever uses Expanded() or Flexible() inside the ListView() or any scrollable widget, cos they require a finite height. use it inside the content but not for Expanded()
Thanks Guys! :)
Reiterating the solution to close the thread. As mentioned in this issue ticket posted on GitHub, TabBarView requires a finite height to be rendered. This can be achieved by using Expanded widget as suggested in the error logs posted and on the solution posted in this GitHub thread
Here's a minimal repro that you can try out
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Expanded(
child: TabWidget(),
),
);
}
}
class TabWidget extends StatefulWidget {
#override
_TabWidgetState createState() => _TabWidgetState();
}
class _TabWidgetState extends State<TabWidget>
with SingleTickerProviderStateMixin {
TabController _controller;
#override
void initState() {
super.initState();
_controller = TabController(length: 3, vsync: this);
}
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
children: <Widget>[
TabBar(
labelColor: Colors.black,
indicatorColor: Colors.blue,
controller: _controller,
tabs: <Widget>[
Tab(
text: 'Tab 1',
),
Tab(
text: 'Tab 2',
),
Tab(
text: 'Tab 3',
),
],
),
Expanded(
child: TabBarView(
controller: _controller,
children: <Widget>[
Center(
child: Text('Tab View 1'),
),
Center(
child: Text('Tab View 2'),
),
Center(
child: Text('Tab View 3'),
),
],
),
)
],
),
);
}
}
How the app looks
Related
I want to have a widget that scrolls vertically with few items on them. At the top of it there should be a horizontal ListView, followed up with gridview. And all this is inside a TabBarView.
I have tried wrapping the horizontal ListView and vertical gridview using SingleChildScrollView as suggested from other's StackOverflow question but it didn't work.
Widget build(BuildContext context) {
List tabs = <Tab>[
Tab(text: "Home"),
Tab(text: "Store"),
Tab(text: "Favourite")
];
return DefaultTabController(
length: 3,
child: Scaffold(
key: _scaffoldKey,
drawer: drawerSidebar(),
backgroundColor: Colors.grey[100],
appBar: AppBar(
actions: <Widget>[
IconButton(
icon: Icon(Icons.notifications),
),
IconButton(
icon: Icon(Icons.message),
),
],
title: TextField(
controller: _filter,
decoration: new InputDecoration(
fillColor: Colors.white, filled: true, hintText: 'Search'),
),
bottom: TabBar(
// indicatorSize: TabBarIndicatorSize.tab,
tabs: tabs,
controller: _tabController,
),
),
body: TabBarView(
children: <Widget>[
SingleChildScrollView(
child:
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Explore(), //horizontal listview
Expanded(
child: FreshFinds(), //vertical gridview.builder
),
],
)),
PageTwo(),
],
)));
}
This is the error i get when using SingleChildScrollView:
I/flutter (18049): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (18049): The following assertion was thrown during performLayout():
I/flutter (18049): RenderFlex children have non-zero flex but incoming height constraints are unbounded.
I/flutter (18049): When a column is in a parent that does not provide a finite height constraint, for example if it is
I/flutter (18049): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
I/flutter (18049): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
I/flutter (18049): space in the vertical direction.
I/flutter (18049): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter (18049): cannot simultaneously expand to fit its parent.
I/flutter (18049): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
I/flutter (18049): children (using Flexible rather than Expanded). This will allow the flexible children to size
I/flutter (18049): themselves to less than the infinite remaining space they would otherwise be forced to take, and
I/flutter (18049): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
I/flutter (18049): constraints provided by the parent.
I/flutter (18049): The affected RenderFlex is:
I/flutter (18049): RenderFlex#46825 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18049): The creator information is set to:
I/flutter (18049): Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#653c5] ← Semantics ← Listener ←
I/flutter (18049): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#61b8a] ←
I/flutter (18049): _ScrollableScope ← _ScrollSemantics-[GlobalKey#7275d] ← RepaintBoundary ← CustomPaint ←
I/flutter (18049): RepaintBoundary ← ⋯
I/flutter (18049): The nearest ancestor providing an unbounded width constraint is:
I/flutter (18049): _RenderSingleChildViewport#72ad5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18049): creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#653c5] ← Semantics ← Listener ←
I/flutter (18049): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#61b8a] ←
I/flutter (18049): _ScrollableScope ← _ScrollSemantics-[GlobalKey#7275d] ← RepaintBoundary ← CustomPaint ←
I/flutter (18049): RepaintBoundary ← NotificationListener<ScrollNotification> ← ⋯
I/flutter (18049): parentData: <none> (can use size)
I/flutter (18049): constraints: BoxConstraints(w=454.7, h=680.4)
I/flutter (18049): size: MISSING
I/flutter (18049): See also: https://flutter.io/layout/
I/flutter (18049): If this message did not help you determine the problem, consider using debugDumpRenderTree():
I/flutter (18049): https://flutter.io/debugging/#rendering-layer
I/flutter (18049): http://docs.flutter.io/flutter/rendering/debugDumpRenderTree.html
I/flutter (18049): If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
I/flutter (18049): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (18049):
My result without using SingleChildScrollView
what I want
So i solved it using CustomScrollView with Slivers
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text("Settings"),
),
body: Container(
child: CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildListDelegate(<Widget>[
Container(
child: new Image.asset(
"images/product.jpg",
fit: BoxFit.fitWidth,
),
),
])),
FreshFinds()
],
),
),
);
}
//Freshfinds.dart
Widget build(BuildContext context) {
return SliverGrid(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
return FutureBuilder(
future: fetchdata(index),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (!snapshot.hasData)
return buildfake(index);
else
return buildcard(snapshot.data, index);
},
);
}, childCount: 20),
);
}
I am trying to make a flutter app. Recently, I have learned how to use hero with two different buttons which all have the same destination. So, I tried to use hero with infinitely creatable containers. This is what I came up with:
import 'package:flutter/material.dart';
void main() => runApp(MainPage());
class MainPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.white,
body: Column(children: <Widget>[
Body(),
])));
}
}
class Body extends StatefulWidget {
#override
_BodyState createState() => _BodyState();
}
class _BodyState extends State<Body> {
final String open1 = 'open';
int count = 1;
#override
Widget build(BuildContext context) {
print(count);
List cards = List.generate(count, (int i) => RCard(count));
return Expanded(
child: Container(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
},
child: PageView.builder(
reverse: true,
pageSnapping: false,
controller: PageController(viewportFraction: 0.85),
itemCount: count,
itemBuilder: (context, i) {
if (i == 0) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Page(
open: open1,
)),
);
count++;
},
child: Hero(
tag: open1,
child: Padding(
padding: EdgeInsets.only(
left:
MediaQuery.of(context).size.height *
0.015,
right:
MediaQuery.of(context).size.height *
0.015,
top: MediaQuery.of(context).size.width *
0.08,
bottom:
MediaQuery.of(context).size.width *
0.15),
child: Material(
borderRadius:
BorderRadius.circular(40.0),
color: Colors.white,
elevation: 8.0,
child: InkWell(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.add,
size: 30.0,
color: Colors.black,
)
]),
)))));
} else {
return cards[i];
}
}))));
}
}
class RCard extends StatefulWidget {
final int count;
RCard(this.count);
#override
RCardState createState() => RCardState();
}
class RCardState extends State<RCard> {
int count;
String open2;
#override
void initState() {
super.initState();
count = widget.count;
open2 = 'open$count';
}
#override
Widget build(BuildContext context) {
return Hero(
tag: open2,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Page(
open: open2,
)),
);
},
child: Padding(
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.height * 0.015,
right: MediaQuery.of(context).size.height * 0.015,
top: MediaQuery.of(context).size.width * 0.08,
bottom: MediaQuery.of(context).size.width * 0.15),
child: Material(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
elevation: 8.0,
child: Padding(
padding:
EdgeInsets.all(MediaQuery.of(context).size.width * 0.15),
)),
)),
);
}
}
class Page extends StatelessWidget {
final String open;
Page({this.open});
#override
Widget build(BuildContext context) {
return GestureDetector(
child: Hero(
tag: open,
child: Material(
child: Center(child: Text('New page')),
)),
onTap: () {
Navigator.pop(context);
},
);
}
}
But, when I create a second container and press on it, It will give a black screen and get an error message in my debug console saying:
flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during a scheduler callback:
flutter: There are multiple heroes that share the same tag within a subtree.
flutter: Within each subtree for which heroes are to be animated (typically a PageRoute subtree), each Hero
flutter: must have a unique non-null tag.
flutter: In this case, multiple heroes had the following tag: opennull
flutter: Here is the subtree for one of the offending heroes:
flutter: # Hero(tag: opennull, state: _HeroState#f299c)
flutter: # └KeyedSubtree-[GlobalKey#45266]
flutter: # └GestureDetector
flutter: # └RawGestureDetector(state: RawGestureDetectorState#98814(gestures: [tap]))
flutter: # └_GestureSemantics(renderObject: RenderSemanticsGestureHandler#59110)
flutter: # └Listener(listeners: [down], behavior: deferToChild, renderObject: RenderPointerListener#5cfa6)
flutter: # └Padding(padding: EdgeInsets(13.4, 33.1, 13.4, 62.1), renderObject: RenderPadding#ab11d)
flutter: # └Material(type: canvas, elevation: 8.0, color: Color(0xffffffff), borderRadius: circular(40.0), state: _MaterialState#a511a)
flutter: # └_MaterialInterior(duration: 200ms, shape: RoundedRectangleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), BorderRadius.circular(40.0)), elevation: 8.0, color: Color(0xffffffff), shadowColor: Color(0xff000000), state: _MaterialInteriorState#6412f(ticker inactive))
flutter: # └PhysicalShape(clipper: ShapeBorderClipper, elevation: 8.0, color: Color(0xffffffff), shadowColor: Color(0xff000000), renderObject: RenderPhysicalShape#1b504)
flutter: # └_ShapeBorderPaint
flutter: # └CustomPaint(renderObject: RenderCustomPaint#94831)
flutter: # └NotificationListener<LayoutChangedNotification>
flutter: # └_InkFeatures-[GlobalKey#8ef37 ink renderer](renderObject: _RenderInkFeatures#670e3)
flutter: # └AnimatedDefaultTextStyle(duration: 200ms, debugLabel: (englishLike body1 2014).merge(blackCupertino body1), inherit: false, color: Color(0xdd000000), family: .SF UI Text, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip, state: _AnimatedDefaultTextStyleState#9cb8b(ticker inactive))
flutter: # └DefaultTextStyle(debugLabel: (englishLike body1 2014).merge(blackCupertino body1), inherit: false, color: Color(0xdd000000), family: .SF UI Text, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip)
flutter: # └Padding(padding: EdgeInsets.all(62.1), renderObject: RenderPadding#0a02b)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Hero._allHeroesFor.visitor.<anonymous closure>
package:flutter/…/widgets/heroes.dart:210
flutter: #1 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:220
flutter: #2 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #3 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #4 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #5 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #6 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #7 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #8 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #9 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #10 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #11 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #12 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #13 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #14 List.forEach (dart:core/runtime/libgrowable_array.dart:278:8)
flutter: #15 SliverMultiBoxAdaptorElement.visitChildren
package:flutter/…/widgets/sliver.dart:1175
flutter: #16 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #17 MultiChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4948
flutter: #18 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #19 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #20 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #21 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #22 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #23 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #24 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #25 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #26 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #27 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #28 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #29 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #30 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #31 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #32 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #33 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #34 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #35 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #36 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #37 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #38 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #39 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #40 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #41 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #42 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #43 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #44 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #45 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #46 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #47 MultiChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4948
flutter: #48 Hero._allHeroesFor.visitor
flutter: #49 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #50 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #51 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #52 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #53 MultiChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4948
flutter: #54 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #55 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #56 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #57 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #58 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #59 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #60 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #61 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #62 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #63 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #64 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #65 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #66 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #67 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #68 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #69 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #70 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #71 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #72 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #73 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #74 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #75 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #76 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #77 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #78 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #79 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:3755
flutter: #80 Hero._allHeroesFor.visitor
package:flutter/…/widgets/heroes.dart:225
flutter: #81 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:4848
flutter: #82 Element.visitChildElements
package:flutter/…/widgets/framework.dart:2686
flutter: #83 Hero._allHeroesFor
package:flutter/…/widgets/heroes.dart:227
flutter: #84 HeroController._startHeroTransition
package:flutter/…/widgets/heroes.dart:655
flutter: #85 HeroController._maybeStartHeroTransition.<anonymous closure>
package:flutter/…/widgets/heroes.dart:630
flutter: #86 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:990
flutter: #87 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:938
flutter: #88 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:842
flutter: #89 _invoke (dart:ui/hooks.dart:154:13)
flutter: #90 _drawFrame (dart:ui/hooks.dart:143:3)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
How anyone please help???
Instead of doing - List.generate in build. Simply Pass RCard directly in PageView.builder
working Code:
import 'package:flutter/material.dart';
void main() => runApp(MainPage());
class MainPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.white,
body: Column(children: <Widget>[
Body(),
])));
}
}
class Body extends StatefulWidget {
#override
_BodyState createState() => _BodyState();
}
class _BodyState extends State<Body> {
final String open1 = 'open';
int count = 1;
#override
Widget build(BuildContext context) {
print(count);
return Expanded(
child: Container(
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
},
child: PageView.builder(
reverse: true,
pageSnapping: false,
controller: PageController(viewportFraction: 0.85),
itemCount: count,
itemBuilder: (context, i) {
if (i == 0) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Page(
open: open1,
)),
);
count++;
},
child: Hero(
tag: open1,
child: Padding(
padding: EdgeInsets.only(
left:
MediaQuery.of(context).size.height *
0.015,
right:
MediaQuery.of(context).size.height *
0.015,
top: MediaQuery.of(context).size.width *
0.08,
bottom:
MediaQuery.of(context).size.width *
0.15),
child: Material(
borderRadius:
BorderRadius.circular(40.0),
color: Colors.white,
elevation: 8.0,
child: InkWell(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.add,
size: 30.0,
color: Colors.black,
)
]),
)))));
} else {
return RCard(i);
}
}))));
}
}
class RCard extends StatefulWidget {
final int count;
RCard(this.count);
#override
RCardState createState() => RCardState();
}
class RCardState extends State<RCard> {
int count;
String open2;
#override
void initState() {
super.initState();
count = widget.count;
open2 = 'open$count';
}
#override
Widget build(BuildContext context) {
return Hero(
tag: open2,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Page(
open: open2,
)),
);
},
child: Padding(
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.height * 0.015,
right: MediaQuery.of(context).size.height * 0.015,
top: MediaQuery.of(context).size.width * 0.08,
bottom: MediaQuery.of(context).size.width * 0.15),
child: Material(
borderRadius: BorderRadius.circular(40.0),
color: Colors.white,
elevation: 8.0,
child: Padding(
padding:
EdgeInsets.all(MediaQuery.of(context).size.width * 0.15),
)),
)),
);
}
}
class Page extends StatelessWidget {
final String open;
Page({this.open});
#override
Widget build(BuildContext context) {
return GestureDetector(
child: Hero(
tag: open,
child: Material(
child: Center(child: Text('New page')),
)),
onTap: () {
Navigator.pop(context);
},
);
}
}
I'm new with flutter & just learned how to retrieve data from firestore & did some UI. Right now I have 2 problems;
1- This is a Setting Page which has CustomScrollView contains ScrollController for the controller.
SettingsPage
The controller working fine with this code
class _SettingsPageState extends State<SettingsPage> {
ScrollController _scrollController;
#override
void initState() {
super.initState();
_scrollController = new ScrollController();
_scrollController.addListener(() => setState(() {}));
}
#override
void dispose() {
_scrollController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Shared.firestore.collection('client').document(Shared.firebaseUser.uid).snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Scaffold(
backgroundColor: Colors.grey[50],
body: Stack(
children: <Widget>[
CustomScrollView(
controller: _scrollController,
slivers: <Widget>[
SliverAppBar(
expandedHeight: 140.0,
pinned: true,
),
SliverFillRemaining(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 8,
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.only(
left: 18.0,
top: 18.0,
),
child: Row(
children: <Widget>[
Text(
"Account",
style: TextStyle(
color: Colors.blue[700],
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
],
),
),
),
Container(
decoration: BoxDecoration(
color: Colors.white,
),
child: ListTile(
onTap: () {},
contentPadding: EdgeInsets.only(left: 18.0),
title: Text(
"+${snapshot.data['countryCode']} ${snapshot.data['phoneNumber']}",
style: TextStyle(fontSize: 16),
),
subtitle: Row(
children: <Widget>[
Text(
"Phone Number",
style: TextStyle(
fontSize: 12,
),
),
],
),
),
),
],
),
),
],
),
),
],
),
],
),
);
},
);
}
}
but this error happened
I/flutter ( 8691): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8691): The following NoSuchMethodError was thrown building StreamBuilder<DocumentSnapshot>(dirty, state:
I/flutter ( 8691): _StreamBuilderBaseState<DocumentSnapshot, AsyncSnapshot<DocumentSnapshot>>#7db43):
I/flutter ( 8691): The method '[]' was called on null.
I/flutter ( 8691): Receiver: null
I/flutter ( 8691): Tried calling: []("countryCode")
I/flutter ( 8691):
I/flutter ( 8691): When the exception was thrown, this was the stack:
I/flutter ( 8691): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter ( 8691): #1 _SettingsPageState.build.<anonymous closure> (package:silkwallet/page/settings.dart:81:54)
I/flutter ( 8691): #2 StreamBuilder.build (package:flutter/src/widgets/async.dart:423:74)
I/flutter ( 8691): #3 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:125:48)
I/flutter ( 8691): #4 StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter ( 8691): #5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 8691): #6 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 8691): #7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 8691): #8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 8691): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 8691): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 8691): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 8691): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 8691): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 8691): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 8691): #15 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 8691): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 8691): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 8691): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 8691): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 8691): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 8691): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 8691): #22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 8691): #23 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 8691): #24 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 8691): #25 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 8691): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 8691): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
.
.
.
I/flutter ( 8691): #135 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter ( 8691): #136 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 8691): #137 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 8691): #138 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 8691): #139 _invoke (dart:ui/hooks.dart:154:13)
I/flutter ( 8691): #140 _drawFrame (dart:ui/hooks.dart:143:3)
2- After some research for this error, I add connectionState condition inside StreamBuilder which solved above problem
this is the new code, i put the Scaffold inside active connectionState
class _SettingsPageState extends State<SettingsPage> {
ScrollController _scrollController;
#override
void initState() {
super.initState();
_scrollController = new ScrollController();
_scrollController.addListener(() => setState(() {}));
}
#override
void dispose() {
_scrollController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Shared.firestore.collection('client').document(Shared.firebaseUser.uid).snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
return Scaffold(
backgroundColor: Colors.grey[50],
body: Stack(
.
.
.
),
);
} else if (snapshot.connectionState == ConnectionState.waiting) {
return Container(child: Center(child: CircularProgressIndicator()));
} else {
return Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.warning),
),
Text('Error in loadind data')
],
),
);
}
},
);
}
}
and I realized that when I scrolled the connectionState will change to waiting and the ScrollController not working under this state as shown in the image below
ScrollController: page keep flashing when try to scroll
The reason I want to use the ScrollController because I want to add FloatingActionButton inside Positioned which will scroll along & disappear when reach certain position, here's the image with FloatingActionButton
NoSuchMethodError the method was called on null errors are usually thrown when the method that you're trying to call from the object is yet to be initialized. The error seems to be coming from snapshot.data['countryCode']. What you can do here is add a null-check on snapshot before displaying the data.
if (snapshot != null && snapshot.hasData) {
// Display data
} else {
// Display circular progress...
}
i have been trying to trigger a dialog-box when the iconButton is click in appBar but error is coming
this error is persistance.
I think that the context passed in the showDialog() have some issue i'm not sure
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
## Heading ##
#override
State<StatefulWidget> createState() {
// TODO: implement createState
return _MyPortfolioState();
}
}
class _MyPortfolioState extends State<MyApp> {
MaterialColor primaryColor = Colors.blue;
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Portfolio',
theme: new ThemeData(
primarySwatch: primaryColor,
),
home: Scaffold(
appBar: AppBar(
title: Text("Dhruv Agarwal"),
textTheme: TextTheme(
display2: TextStyle(color: Color.fromARGB(1, 0, 0, 0))),
actions: <Widget>[
new IconButton(
icon: Icon(Icons.format_color_text),
tooltip: 'Change Color',
onPressed: () {
Color pickerColor = primaryColor;
changeColor(Color color) {
setState(() => primaryColor = color);
}
showDialog (
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Pick a color!'),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: pickerColor,
onColorChanged: changeColor,
pickerAreaHeightPercent: 0.8,
),
),
actions: <Widget>[
FlatButton(
child: Text('Got it'),
onPressed: () {
setState(() => primaryColor = pickerColor);
Navigator.of(context).pop();
},
),
],
);
});
},
),
])));
}
}
//
//
The exception is thrown on reload that No MaterialLocalizations found.
Launching lib/main.dart on Redmi Note 5 Pro in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
I/zygote64(16669): Do partial code cache collection, code=28KB, data=20KB
I/zygote64(16669): After code cache collection, code=28KB, data=20KB
I/zygote64(16669): Increasing code cache capacity to 128KB
Syncing files to device Redmi Note 5 Pro...
I/flutter (16669): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (16669): The following assertion was thrown while handling a gesture:
I/flutter (16669): No MaterialLocalizations found.
I/flutter (16669): MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
I/flutter (16669): Localizations are used to generate many different messages, labels,and abbreviations which are used
I/flutter (16669): by the material library.
I/flutter (16669): To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to
I/flutter (16669): include them automatically, or add a Localization widget with a MaterialLocalizations delegate.
I/flutter (16669): The specific widget that could not find a MaterialLocalizations ancestor was:
I/flutter (16669): MyApp
I/flutter (16669): The ancestors of this widget were:
I/flutter (16669): [root]
I/flutter (16669):
I/flutter (16669): When the exception was thrown, this was the stack:
I/flutter (16669): #0 debugCheckHasMaterialLocalizations.<anonymous closure> (package:flutter/src/material/debug.dart:124:7)
I/flutter (16669): #1 debugCheckHasMaterialLocalizations (package:flutter/src/material/debug.dart:127:4)
I/flutter (16669): #2 showDialog (package:flutter/src/material/dialog.dart:606:10)
I/flutter (16669): #3 MyApp.build.<anonymous closure> (file:///home/punisher/AndroidStudioProjects/first_app/portfolio/lib/main.dart:32:19)
I/flutter (16669): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
I/flutter (16669): #5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
I/flutter (16669): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter (16669): #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
I/flutter (16669): #8 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
I/flutter (16669): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
I/flutter (16669): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
I/flutter (16669): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
I/flutter (16669): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
I/flutter (16669): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
I/flutter (16669): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
I/flutter (16669): #15 _invoke1 (dart:ui/hooks.dart:153:13)
I/flutter (16669): #16 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)
I/flutter (16669):
I/flutter (16669): Handler: onTap
I/flutter (16669): Recognizer:
I/flutter (16669): TapGestureRecognizer#5070d(debugOwner: GestureDetector, state: ready, won arena, finalPosition:
I/flutter (16669): Offset(354.2, 64.0), sent tap down)
I/flutter (16669): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (16669): Another exception was thrown: No MaterialLocalizations found.
Some Material Widget in your tree requires localization to be set, so instead of running directly your app from a StatefulWidget, wrap it in a MaterialApp. So the MaterialApp will have your Widget as its child, and not the contrary.
main() => runApp(
MaterialApp(
title: 'ColorPicker test',
home: MyApp(),
),
);
The MaterialApp will setup the MaterialLocalizations in the widget tree and its children will be able to use it.
By the way, your code won't work as the ColorPicker chooses from all possible colors and the primarySwatch can only be MaterialColors. You can try again using a material ColorPicker. I think this plugin also provides it, you can check this one too.
I'm trying to create a form for my app containing two columns inside a row. Should look something like this:
But when I run this code:
#override
Widget build(BuildContext context) {
return /*new Padding (
padding: const EdgeInsets.all(15.0),
child: */new ListView (
//mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[new Row (children: <Widget>[
// Goal + Amount
new ListTile (
title: new Column (
mainAxisSize: MainAxisSize.min,
children: <Widget>[new Expanded(child: new TextField(
controller: widget._NameController,
style: new TextStyle (
fontSize: 20.0,
color: Colors.black,
),
decoration: new InputDecoration(
labelText: 'Name'
),
)), new Expanded(child:
new FlatButton(
onPressed: _showDatePicker,
child: new Text(
PARTIAL_DATE_FORMAT.format(_pickedDate)),
)),
]
)
),
// Goal Deadline
new ListTile (
title: new Column (
mainAxisSize: MainAxisSize.min,
children: <Widget>[new Expanded(child: new ListTile (
title: new TextField(
//controller: widget._TextController,,
style: new TextStyle (
fontSize: 20.0,
color: Colors.black
),
decoration: new InputDecoration(
labelText: 'Amount'
),
)
)), new Expanded(child:
new FlatButton(
onPressed: _showTimePicker,
child: new Text(_pickedTime.format(context)),
)),
]
)
),
]),
// Goal Description
new ListTile (
title: new TextField(
controller: widget._DescriptionController,
style: new TextStyle (
fontSize: 20.0,
color: Colors.black
),
decoration: new InputDecoration(
labelText: 'Description'
),
)
),
]
);
}
It resolves in this error:
I/flutter ( 2837): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 2837): The following assertion was thrown during performLayout():
I/flutter ( 2837): RenderFlex children have non-zero flex but incoming width constraints are unbounded.
I/flutter ( 2837): When a row is in a parent that does not provide a finite width constraint, for example if it is in a
I/flutter ( 2837): horizontal scrollable, it will try to shrink-wrap its children along the horizontal axis. Setting a
I/flutter ( 2837): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
I/flutter ( 2837): space in the horizontal direction.
I/flutter ( 2837): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter ( 2837): cannot simultaneously expand to fit its parent.
I/flutter ( 2837): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
I/flutter ( 2837): children (using Flexible rather than Expanded). This will allow the flexible children to size
I/flutter ( 2837): themselves to less than the infinite remaining space they would otherwise be forced to take, and
I/flutter ( 2837): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
I/flutter ( 2837): constraints provided by the parent.
I/flutter ( 2837): The affected RenderFlex is:
I/flutter ( 2837): RenderFlex#770e0 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): The creator information is set to:
I/flutter ( 2837): Row ← Padding ← ConstrainedBox ← Container ← Listener ← _GestureSemantics ← RawGestureDetector ←
I/flutter ( 2837): GestureDetector ← InkWell ← ListTile ← Row ← RepaintBoundary-[<0>] ← ⋯
I/flutter ( 2837): The nearest ancestor providing an unbounded width constraint is:
I/flutter ( 2837): RenderFlex#47431 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): creator: Row ← RepaintBoundary-[<0>] ← NotificationListener<KeepAliveNotification> ← KeepAlive ←
I/flutter ( 2837): AutomaticKeepAlive ← SliverList ← Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#60f18] ←
I/flutter ( 2837): Listener ← _GestureSemantics ←
I/flutter ( 2837): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#f4728] ← ⋯
I/flutter ( 2837): parentData: <none> (can use size)
I/flutter ( 2837): constraints: BoxConstraints(w=381.4, 0.0<=h<=Infinity)
I/flutter ( 2837): size: MISSING
I/flutter ( 2837): direction: horizontal
I/flutter ( 2837): mainAxisAlignment: start
I/flutter ( 2837): mainAxisSize: max
I/flutter ( 2837): crossAxisAlignment: center
I/flutter ( 2837): textDirection: ltr
I/flutter ( 2837): verticalDirection: downSee also: https://flutter.io/layout/
I/flutter ( 2837): If this message did not help you determine the problem, consider using debugDumpRenderTree():
I/flutter ( 2837): https://flutter.io/debugging/#rendering-layer
I/flutter ( 2837): http://docs.flutter.io/flutter/rendering/debugDumpRenderTree.html
I/flutter ( 2837): If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
I/flutter ( 2837): https://github.com/flutter/flutter/issues/new
I/flutter ( 2837): When the exception was thrown, this was the stack:
I/flutter ( 2837): #0 RenderFlex.performLayout.<anonymous closure> (package:flutter/src/rendering/flex.dart:690:11)
I/flutter ( 2837): #1 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:711:10)
I/flutter ( 2837): #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #3 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:197:11)
I/flutter ( 2837): #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #5 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:257:13)
I/flutter ( 2837): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #7 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #9 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #11 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:737:15)
I/flutter ( 2837): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #13 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #15 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:164:27)
I/flutter ( 2837): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #17 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:286:13)
I/flutter ( 2837): #18 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:979:12)
I/flutter ( 2837): #19 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:903:20)
I/flutter ( 2837): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #21 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #23 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #25 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #27 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #29 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #31 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #33 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:197:11)
I/flutter ( 2837): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #35 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:124:11)
I/flutter ( 2837): #36 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:91:7)
I/flutter ( 2837): #37 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:194:7)
I/flutter ( 2837): #38 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:338:14)
I/flutter ( 2837): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #40 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #42 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #43 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1005:24)
I/flutter ( 2837): #44 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #45 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #47 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #49 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #50 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #51 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2747:14)
I/flutter ( 2837): #52 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #53 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107:13)
I/flutter ( 2837): #54 RenderObject.layout (package:flutter/src/rendering/object.dart:1962:7)
I/flutter ( 2837): #55 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:466:15)
I/flutter ( 2837): #56 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1837:7)
I/flutter ( 2837): #57 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1126:18)
I/flutter ( 2837): #58 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:262
:19)
I/flutter ( 2837): #59 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/bin
ding.dart:581:22)
I/flutter ( 2837): #60 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rende
ring/binding.dart:200:5)
I/flutter ( 2837): #61 BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:713:15)
I/flutter ( 2837): #62 BindingBase&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:649:9)
I/flutter ( 2837): #63 _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:91)
I/flutter ( 2837): #64 _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:80)
I/flutter ( 2837): The following RenderObject was being processed when the exception was fired:
I/flutter ( 2837): RenderFlex#770e0 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): creator: Row ← Padding ← ConstrainedBox ← Container ← Listener ← _GestureSemantics ←
I/flutter ( 2837): RawGestureDetector ← GestureDetector ← InkWell ← ListTile ← Row ← RepaintBoundary-[<0>] ← ⋯
I/flutter ( 2837): parentData: offset=Offset(0.0, 0.0) (can use size)
I/flutter ( 2837): constraints: BoxConstraints(0.0<=w<=Infinity, h=56.0)
I/flutter ( 2837): size: MISSING
I/flutter ( 2837): direction: horizontal
I/flutter ( 2837): mainAxisAlignment: start
I/flutter ( 2837): mainAxisSize: max
I/flutter ( 2837): crossAxisAlignment: center
I/flutter ( 2837): textDirection: ltr
I/flutter ( 2837): verticalDirection: down
I/flutter ( 2837): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 2837): RenderFlex#5610b NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderSemanticsGestureHandler#6d25d NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderPointerListener#4eb7b NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderConstrainedBox#3d105 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderStack#f6a43 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderConstrainedBox#13bd4 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderSemanticsGestureHandler#905d0 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderPointerListener#ec2c3 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): RenderPadding#2b663 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 2837): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1433 pos 12: 'hasSize': is not true.
I/flutter ( 2837): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 458 pos 12: 'child.hasSiz
e': is not true.
I/flutter ( 2837): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter ( 2837): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
I'm very new to flutter and having a lot of trouble working with it due to the lack of information on the internet about that.
I have a created a simple example to show you how you can approach building the desired layout, the usage of ListTile in your code is really confusing and should not be used in this way. The information you provided are not clear enough on what the different elements in your layout represents. That is why I am filling them with a Container, you should be able to provide any widget as child of the container to get started.
import "package:flutter/material.dart";
class Layout extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(),
body: new Padding(
padding: const EdgeInsets.all(30.0),
child:new Column(
children: <Widget>[
new Row(
children: <Widget>[
new SizedBox(
height: 30.0 ,
width: 200.0,
child: new Container(color: Colors.redAccent,),
),
new Container(width: 40.0,),
new SizedBox(
height: 30.0,
width: 50.0,
child: new Container(color:Colors.amberAccent),
)
],
),
new Container(height: 30.0,),
new Row(
children: <Widget>[
new SizedBox(
height: 40.0 ,
width: 100.0,
child: new Container(color: Colors.redAccent,),
),
new Container(width: 140.0,),
new SizedBox(
height: 40.0,
width: 50.0,
child: new Container(color:Colors.amberAccent),
)
],
),
new Container(height: 30.0,),
new Container(color: Colors.tealAccent,width: 290.0,height: 320.0,)
],
),),
);
}
}
Update
I believe you are trying to do similar layout to the following one, the real problem with your code is using ListTile, ListTiles are used to store minimal information (like contact lists for example), and should not be used to contain nested widgets because they are limited in size.
Secondly, I was only doing the previous example as a demonstration, however, yes you are correct about the fixed size problems. In order to avoid this you can use check FractionallySizedBox, or like I did at the very end of the ListView here, using MediaQuery.of(context).size.height*0.3 gave me a Container with height that is 30% of the total screen height.
import "package:flutter/material.dart";
class Layout extends StatefulWidget {
#override
_LayoutState createState() => new _LayoutState();
}
class _LayoutState extends State<Layout> {
String time = "Set Time";
String date = "Set Date ";
String dropDownString;
_showDate(BuildContext context) async {
var datePicked = await showDatePicker(context: context,
initialDate: new DateTime.now(),
firstDate: new DateTime(2010, 2),
lastDate: new DateTime(2018, 1));
setState(() {
date = "${datePicked.month}/${datePicked.day}/${datePicked.year}";
});
}
_showTime(BuildContext context) async {
var timePicked = await showTimePicker(
context: context, initialTime: new TimeOfDay.now());
setState(() {
time = "${timePicked.hour}:${timePicked.minute} ";
});
}
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("Layout Example"),),
body: new Padding(padding: const EdgeInsets.all(20.0),
child: new ListView(
//shrinkWrap: true,
children: <Widget>[
new Row(
children: <Widget>[
new Expanded(child: new TextField()),
new Expanded(child: new FlatButton(
onPressed: () => _showDate(context),
child: new Text(date))),
],
),
new Row(
children: <Widget>[
new Expanded(child: new TextField()),
new Expanded(child: new FlatButton(
onPressed: () => _showTime(context),
child: new Text(time))),
],),
new TextField(
maxLines: 5,
),
new Container(
height: MediaQuery.of(context).size.height*0.3,
color: Colors.tealAccent,
)
],
),
),
);
}
}