Open geek-atif opened 4 years ago
just wrap it with Container
I solved this by using the Flex
widget instead of a Column
. I also had to wrap the SearchBar
in a Flexible
Widget.
Flex(
direction: Axis.vertical,
children: [
Text('Search'),
Flexible(
child: SearchBar<Post>(
...
),
),
],
),
Getting error while using in Column. Error Log: I/flutter ( 3527): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════ I/flutter ( 3527): The following assertion was thrown during performLayout(): I/flutter ( 3527): RenderFlex children have non-zero flex but incoming height constraints are unbounded. I/flutter ( 3527): When a column is in a parent that does not provide a finite height constraint, for example if it is I/flutter ( 3527): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a I/flutter ( 3527): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining I/flutter ( 3527): space in the vertical direction. I/flutter ( 3527): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child I/flutter ( 3527): cannot simultaneously expand to fit its parent. I/flutter ( 3527): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible I/flutter ( 3527): children (using Flexible rather than Expanded). This will allow the flexible children to size I/flutter ( 3527): themselves to less than the infinite remaining space they would otherwise be forced to take, and I/flutter ( 3527): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum I/flutter ( 3527): constraints provided by the parent. I/flutter ( 3527): If this message did not help you determine the problem, consider using debugDumpRenderTree(): I/flutter ( 3527): https://flutter.dev/debugging/#rendering-layer I/flutter ( 3527): http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html I/flutter ( 3527): The affected RenderFlex is: I/flutter ( 3527): RenderFlex#50a43 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← SearchBar ← Padding ← Container ← MySearchBar ← Column ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← ⋯, parentData: offset=Offset(0.0, 0.0) (can use size), constraints: BoxConstraints(0.0<=w<=391.4, 0.0<=h<=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: start, textDirection: ltr, verticalDirection: down)
I/flutter ( 3527): The creator information is set to:
I/flutter ( 3527): Column ← SearchBar ← Padding ← Container ← MySearchBar ← Column ← _BodyBuilder ← MediaQuery
I/flutter ( 3527): Column ← SearchBar ← Padding ← Container ← MySearchBar ← Column ← _BodyBuilder ← MediaQuery
I/flutter ( 3527): ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ←
I/flutter ( 3527): ⋯
I/flutter ( 3527): The nearest ancestor providing an unbounded width constraint is: RenderFlex#e54e5 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter ( 3527): creator: Column ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ←
I/flutter ( 3527): CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
I/flutter ( 3527): _InkFeatures-[GlobalKey#2d979 ink renderer] ← NotificationListener ←
I/flutter ( 3527): PhysicalModel ← AnimatedPhysicalModel ← ⋯
I/flutter ( 3527): parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
I/flutter ( 3527): constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=843.4)
I/flutter ( 3527): size: MISSING
I/flutter ( 3527): direction: vertical
I/flutter ( 3527): mainAxisAlignment: start
I/flutter ( 3527): mainAxisSize: max
I/flutter ( 3527): crossAxisAlignment: center
I/flutter ( 3527): verticalDirection: down
I/flutter ( 3527): See also: https://flutter.dev/layout/
I/flutter ( 3527): If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
I/flutter ( 3527): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter ( 3527):
I/flutter ( 3527): The relevant error-causing widget was:
I/flutter ( 3527): Column
I/flutter ( 3527):
package:flutter/…/rendering/flex.dart:693
I/flutter ( 3527): #1 RenderFlex.performLayout
..\…\lib\flappy_search_bar.dart:330 I/flutter ( 3527): I/flutter ( 3527): When the exception was thrown, this was the stack: I/flutter ( 3527): #0 RenderFlex.performLayout.
I/flutter ( 3527): The following RenderObject was being processed when the exception was fired: RenderFlex#50a43 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: I/flutter ( 3527): creator: Column ← SearchBar ← Padding ← Container ← MySearchBar ← Column ← _BodyBuilder ←
I/flutter ( 3527): MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← CustomMultiChildLayout ← AnimatedBuilder ←
I/flutter ( 3527): DefaultTextStyle ← ⋯
I/flutter ( 3527): parentData: offset=Offset(0.0, 0.0) (can use size)
I/flutter ( 3527): constraints: BoxConstraints(0.0<=w<=391.4, 0.0<=h<=Infinity)
I/flutter ( 3527): size: MISSING
I/flutter ( 3527): direction: vertical
I/flutter ( 3527): mainAxisAlignment: start
I/flutter ( 3527): mainAxisSize: max
I/flutter ( 3527): crossAxisAlignment: start
I/flutter ( 3527): textDirection: ltr
I/flutter ( 3527): verticalDirection: down
I/flutter ( 3527): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 3527): child 1: RenderPadding#aae4d relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 3527): child: RenderConstrainedBox#846be relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 3527): child: RenderFlex#f2dfa relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter ( 3527): child: RenderDecoratedBox#ed770 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child 2: RenderSemanticsGestureHandler#7eb3b relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderPointerListener#79446 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child 2: RenderPadding#078d8 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderLimitedBox#a0b39 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderConstrainedBox#18794 relayoutBoundary=up6 NEEDS-PAINT I/flutter ( 3527): child 3: RenderPadding#14964 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderRepaintBoundary#0e907 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderCustomPaint#47d7e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: RenderRepaintBoundary#65e49 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): child: _RenderScrollSemantics#be84d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter ( 3527): Another exception was thrown: RenderBox was not laid out: RenderFlex#50a43 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): Another exception was thrown: RenderBox was not laid out: RenderPadding#3b209 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): Another exception was thrown: RenderBox was not laid out: RenderFlex#e54e5 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter ( 3527): Another exception was thrown: NoSuchMethodError: The method '>' was called on null. I/Choreographer( 3527): Skipped 30 frames! The application may be doing too much work on its main thread.