marquee
marquee copied to clipboard
Exception while building and running
Everytime I try to build the project after adding this library, I get exception throw and the debug build stops Exception thrown at
await _makeRoundTrip();
return _running && !isDone;
}
A complete log is here:
I/flutter (19927): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (19927): The following assertion was thrown during performResize():
I/flutter (19927): Horizontal viewport was given unbounded width.
I/flutter (19927): Viewports expand in the scrolling direction to fill their container. In this case, a horizontal
I/flutter (19927): viewport was given an unlimited amount of horizontal space in which to expand. This situation
I/flutter (19927): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (19927): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (19927): there will always be enough horizontal space for the children. In this case, consider using a Row
I/flutter (19927): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (19927): the width of the viewport to the sum of the widths of its children.
I/flutter (19927):
I/flutter (19927): The relevant error-causing widget was:
I/flutter (19927): ListView
I/flutter (19927):
package:marquee/marquee.dart:691
I/flutter (19927):
I/flutter (19927): When the exception was thrown, this was the stack:
I/flutter (19927): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter (19927):
I/flutter (19927): The following RenderObject was being processed when the exception was fired: RenderViewport#12a42 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter (19927): needs compositing
I/flutter (19927): creator: Viewport ← IgnorePointer-[GlobalKey#6e389] ← Semantics ← _PointerListener ← Listener ←
I/flutter (19927): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#ae98d] ←
I/flutter (19927): _PointerListener ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#33636] ←
I/flutter (19927): RepaintBoundary ← ⋯
I/flutter (19927): parentData: <none> (can use size)
I/flutter (19927): constraints: BoxConstraints(unconstrained)
I/flutter (19927): size: MISSING
I/flutter (19927): axisDirection: right
I/flutter (19927): crossAxisDirection: down
I/flutter (19927): offset: ScrollPositionWithSingleContext#55548(offset: 0.0, range: null..null, viewport: null,
I/flutter (19927): ScrollableState, NeverScrollableScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#1ad9d,
I/flutter (19927): ScrollDirection.idle)
I/flutter (19927): anchor: 0.0
I/flutter (19927): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (19927): center child: RenderSliverPadding#f57e1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I/flutter (19927): child: RenderSliverList#d5a5a NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19927): ════════════════════════════════════════════════════════════════════════════════════════════════════
Also, I use the widget inside Row widget for which I have looked at other issue and added the necessary Expanded widget as a parent one.
Please help.
Your Row is probably wrapped inside another widget that gives its children unbounded horizontal space.
Like another Row or a horizontal ListView. You should handle those cases as well.
If you need more help, don't hesitate to post the source code here.
How could I handle this case? I'm getting the same error for both vertical and horizontal listviews
Widget build(BuildContext context) {
return Swiper( // <--------------- Swiper is basically a horizontal ListView
onTap: (index) => onTap(events[index]),
itemCount: events.length,
itemBuilder: (context, index) {
final event = events[index];
return Center(
child: Stack(
children: [
_buildImage(event),
_buildText(event),
],
),
);
},
);
}
Widget _buildText(Event event) {
return Positioned(
left: 0,
right: 20,
bottom: 20,
child: Hero(
tag: '${event.name.getOrCrash()}/name',
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(kDefaultFullRoundedRadius),
bottomRight: Radius.circular(kDefaultFullRoundedRadius),
),
),
padding: const EdgeInsets.symmetric(vertical: 5)
.copyWith(left: 25, right: 15),
child: Marquee(text: event.name.getOrCrash()), // <--------------------------
),
),
);
}