我目前正在学习Flutter,我正在尝试使用Stacked中的Positioned小部件将轮播放置在屏幕底部。当前,堆栈是一张地图,其顶部是旋转木马。当我使用定位的小部件将转盘移动到底部时,它消失了,并且遇到了这个错误。
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#51ed3 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT
Restarted application in 1,970ms.
I/flutter (19228): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (19228): The following assertion was thrown during performResize():
I/flutter (19228): Horizontal viewport was given unbounded width.
I/flutter (19228): Viewports expand in the scrolling direction to fill their container.In this case, a horizontal
I/flutter (19228): viewport was given an unlimited amount of horizontal space in which to expand. This situation
I/flutter (19228): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (19228): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (19228): there will always be enough horizontal space for the children. In this case, consider using a Row
I/flutter (19228): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (19228): the width of the viewport to the sum of the widths of its children.
I/flutter (19228):
I/flutter (19228): When the exception was thrown, this was the stack:
I/flutter (19228): #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1155:15)
I/flutter (19228): #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
I/flutter (19228): #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
I/flutter (19228): #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #13 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #15 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #21 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:258:13)
I/flutter (19228): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:549:15)
I/flutter (19228): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #25 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (19228): #26 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (19228): #27 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (19228): #28 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (19228): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #33 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11)
I/flutter (19228): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #37 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #38 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #39 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #40 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #41 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #42 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #43 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #44 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #45 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #47 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #49 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #50 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (19228): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #52 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (19228): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #54 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #55 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #57 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #62 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #63 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #64 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #65 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #66 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #67 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #68 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #69 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #70 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #71 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #72 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #73 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #74 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #75 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #76 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #77 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #78 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #79 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #80 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #81 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (19228): #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #83 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (19228): #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #85 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #86 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #87 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #88 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #89 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #90 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #91 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #92 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #93 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #95 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #97 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
I/flutter (19228): #98 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (19228): #99 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (19228): #100 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (19228): #101 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (19228): #102 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (19228): #103 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (19228): #104 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (19228): #105 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter (19228): #107 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (19228): #108 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (19228): #109 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (19228): (elided one frame from package dart:async)
I/flutter (19228):
I/flutter (19228): The following RenderObject was being processed when the exception was fired:
I/flutter (19228): RenderViewport#90797 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#3c2b1] ← Semantics ← Listener ←
I/flutter (19228): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#cd194] ←
I/flutter (19228): _ScrollSemantics-[GlobalKey#45621] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (19228): NotificationListener<ScrollNotification> ← ⋯
I/flutter (19228): parentData: <none> (can use size)
I/flutter (19228): constraints: BoxConstraints(0.0<=w<=Infinity, h=180.0)
I/flutter (19228): size: MISSING
I/flutter (19228): axisDirection: right
I/flutter (19228): crossAxisDirection: down
I/flutter (19228): offset: _PagePosition#6c97d(offset: null, range: null..null, viewport: null, ScrollableState,
I/flutter (19228): PageScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#73c09, ScrollDirection.idle)
I/flutter (19228): anchor: 0.0
I/flutter (19228): This RenderObject had the following child:
I/flutter (19228): RenderSliverFillViewport#ce224 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderViewport#90797 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderViewport#90797 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#598aa relayoutBoundary=up11 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#4c977 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#2c082 relayoutBoundary=up9 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#e6e8c relayoutBoundary=up8 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#92ccd relayoutBoundary=up7 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#443e3 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#4e459 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#b5d9f relayoutBoundary=up2 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#b5d9f relayoutBoundary=up2
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/chatty (19228): uid=10100(com.example.mapview) Thread-2 identical 13 lines
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
这是我的堆栈代码
return new MaterialApp(
home: Scaffold(
appBar: new AppBar(title: new Text("Commonwealth Walkway Offline Map")),
body: Stack(
children: <Widget>[
FlutterMap(
mapController: mapController,
options: new MapOptions(
center: new LatLng(51.1747, -115.56934),
minZoom: 13.0,
maxZoom: 16.0,
zoom: 14.0,
swPanBoundary: LatLng(51.16968, -115.58628),
nePanBoundary: LatLng(51.1883, -115.5516),
),
layers: [
new TileLayerOptions(
offlineMode: true,
maxZoom: 16,
urlTemplate: "assets/map/banff/{z}/{x}/{y}.png",
),
new MarkerLayerOptions(
markers: generateMarkers(
markers,
swiperController.move,
_currentIndex,
LatLng(51.17360, -115.57140),
_direction)), //_currentLocation
],
),
Positioned(
bottom: 1.0,
child: Container(
color: Colors.blue,
height: 150.0,
child: Swiper(
itemBuilder: (BuildContext context, index) {
return Carousels(markers[index], _update);
},
itemCount: markers.length,
viewportFraction: 0.8,
scale: 0.9,
loop: false,
controller: swiperController,
onIndexChanged: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
)
],
),
),
);
可以在以下位置找到Swiper / Carousel软件包:https://pub.dartlang.org/packages/flutter_swiper#-readme-tab-
答案 0 :(得分:0)
如您的日志所述:
“约束:BoxConstraints(0.0 <= w <= Infinity,h = 180.0)”
您必须定义Container
的父级Swiper
的宽度。您还必须组织堆栈中未使用行和列定位的项目,以使其在不同屏幕上的布局保持一致。
将此行添加到您的Container
中:
width: MediaQuery.of(context).size.width,
这将使您的Swiper
充满屏幕width
,您可以将其修改为适合您设计的任何其他值。