Custom widget crash when I insert it inside a Column / Flutter
When I include the Tutorial class that I create inside the children of a Column class I get this error:
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 20.7s
Syncing files to device iPhone XR...
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performResize():
flutter: Horizontal viewport was given unbounded height.
flutter: Viewports expand in the cross axis to fill their container and constrain their children to match
flutter: their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
flutter: vertical space in which to expand.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1170:15)
flutter: #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
flutter: #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
flutter: #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #13 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #15 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
flutter: #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #36 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
flutter: #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #38 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #40 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #52 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
flutter: #53 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: #54 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: #55 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: #56 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
flutter: #57 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: #58 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #59 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #60 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
flutter: #62 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
flutter: #63 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
flutter: #64 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#608ab] ← Semantics ← Listener ←
flutter: _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#19222] ←
flutter: _ScrollSemantics-[GlobalKey#0390f] ← Scrollable ← NotificationListener<ScrollNotification> ←
flutter: PageView ← Stack ← ⋯
flutter: parentData: <none> (can use size)
flutter: constraints: BoxConstraints(0.0<=w<=414.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: axisDirection: right
flutter: crossAxisDirection: down
flutter: offset: _PagePosition#edc3e(offset: null, range: null..null, viewport: null, ScrollableState,
flutter: PageScrollPhysics -> AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
flutter: IdleScrollActivity#95217, ScrollDirection.idle)
flutter: anchor: 0.0
flutter: This RenderObject had the following child:
flutter: RenderSliverFillViewport#5d322 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#cca00 relayoutBoundary=up6 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#498e5 relayoutBoundary=up5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a32d0 relayoutBoundary=up4 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#cbf64 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#11d99 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#d9de7 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#554a3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#1d6d0 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#b279d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#e430d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#e8e8f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#a3175 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#4ca11 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#0d592 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#7d38e NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderOffstage#4e5b5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#4e841 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderTheatre#f534f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#85a31 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderAbsorbPointer#a08a9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#f45f1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#5dcca
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
My code is:
import 'package:flutter/material.dart';
import 'Components/Tutorial.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white,
decoration: TextDecoration.none
),
),
),
Tutorial()
],
),
);
}
}
This only happens when I insert Tutorial inside a Column. I try many things but I don't understand why the crash!
And the file with the Tutorial class:
Import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
}) : super(listenable: controller);
/// The PageController that this DotsIndicator is representing.
final PageController controller;
/// The number of items managed by the PageController
final int itemCount;
/// Called when a dot is tapped
final ValueChanged<int> onPageSelected;
/// The color of the dots.
///
/// Defaults to `Colors.white`.
final Color color;
// The base size of the dots
static const double _kDotSize = 8.0;
// The increase in the size of the selected dot
static const double _kMaxZoom = 2.0;
// The distance between the center of each dot
static const double _kDotSpacing = 25.0;
Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
0.0,
1.0 - ((controller.page ?? controller.initialPage) - index).abs(),
),
);
double zoom = 1.0 + (_kMaxZoom - 1.0) * selectedness;
return Container(
width: _kDotSpacing,
child: Center(
child: Material(
color: color,
type: MaterialType.circle,
child: Container(
width: _kDotSize * zoom,
height: _kDotSize * zoom,
child: InkWell(
onTap: () => onPageSelected(index),
),
),
),
),
);
}
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(itemCount, _buildDot),
);
}
}
class Tutorial extends StatefulWidget {
@override
State createState() => TutorialState();
}
class TutorialState extends State<Tutorial> {
final _controller = PageController(viewportFraction: 0.5);
static const _kDuration = const Duration(milliseconds: 300);
static const _kCurve = Curves.ease;
final _kArrowColor = Colors.black.withOpacity(0.8);
static onTap(index) {
print("$index selected.");
}
final List<Widget> _pages = <Widget>[
FlutterLogo(colors: Colors.blue),
FlutterLogo(style: FlutterLogoStyle.stacked, colors: Colors.red),
FlutterLogo(style: FlutterLogoStyle.horizontal, colors: Colors.green),
];
Widget _buildPageItem(BuildContext context, int index) {
return Page(page: _pages[index], idx: index);
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
PageView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _controller,
itemCount: _pages.length,
itemBuilder: (BuildContext context, int index) {
return _buildPageItem(context, index % _pages.length);
},
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.grey[800].withOpacity(0.5),
padding: const EdgeInsets.all(20.0),
child: Center(
child: DotsIndicator(
controller: _controller,
itemCount: _pages.length,
onPageSelected: (int page) {
_controller.animateToPage(
page,
duration: _kDuration,
curve: _kCurve,
);
},
),
),
),
),
],
);
}
}
class Page extends StatelessWidget {
final page;
final idx;
Page({
@required this.page,
@required this.idx,
});
onTap() {
print("${this.idx} selected.");
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0)
);
}
}
What is the error? What am I doing wrong?
flutter flutter-layout
add a comment |
When I include the Tutorial class that I create inside the children of a Column class I get this error:
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 20.7s
Syncing files to device iPhone XR...
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performResize():
flutter: Horizontal viewport was given unbounded height.
flutter: Viewports expand in the cross axis to fill their container and constrain their children to match
flutter: their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
flutter: vertical space in which to expand.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1170:15)
flutter: #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
flutter: #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
flutter: #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #13 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #15 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
flutter: #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #36 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
flutter: #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #38 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #40 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #52 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
flutter: #53 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: #54 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: #55 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: #56 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
flutter: #57 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: #58 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #59 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #60 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
flutter: #62 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
flutter: #63 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
flutter: #64 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#608ab] ← Semantics ← Listener ←
flutter: _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#19222] ←
flutter: _ScrollSemantics-[GlobalKey#0390f] ← Scrollable ← NotificationListener<ScrollNotification> ←
flutter: PageView ← Stack ← ⋯
flutter: parentData: <none> (can use size)
flutter: constraints: BoxConstraints(0.0<=w<=414.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: axisDirection: right
flutter: crossAxisDirection: down
flutter: offset: _PagePosition#edc3e(offset: null, range: null..null, viewport: null, ScrollableState,
flutter: PageScrollPhysics -> AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
flutter: IdleScrollActivity#95217, ScrollDirection.idle)
flutter: anchor: 0.0
flutter: This RenderObject had the following child:
flutter: RenderSliverFillViewport#5d322 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#cca00 relayoutBoundary=up6 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#498e5 relayoutBoundary=up5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a32d0 relayoutBoundary=up4 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#cbf64 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#11d99 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#d9de7 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#554a3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#1d6d0 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#b279d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#e430d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#e8e8f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#a3175 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#4ca11 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#0d592 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#7d38e NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderOffstage#4e5b5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#4e841 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderTheatre#f534f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#85a31 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderAbsorbPointer#a08a9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#f45f1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#5dcca
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
My code is:
import 'package:flutter/material.dart';
import 'Components/Tutorial.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white,
decoration: TextDecoration.none
),
),
),
Tutorial()
],
),
);
}
}
This only happens when I insert Tutorial inside a Column. I try many things but I don't understand why the crash!
And the file with the Tutorial class:
Import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
}) : super(listenable: controller);
/// The PageController that this DotsIndicator is representing.
final PageController controller;
/// The number of items managed by the PageController
final int itemCount;
/// Called when a dot is tapped
final ValueChanged<int> onPageSelected;
/// The color of the dots.
///
/// Defaults to `Colors.white`.
final Color color;
// The base size of the dots
static const double _kDotSize = 8.0;
// The increase in the size of the selected dot
static const double _kMaxZoom = 2.0;
// The distance between the center of each dot
static const double _kDotSpacing = 25.0;
Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
0.0,
1.0 - ((controller.page ?? controller.initialPage) - index).abs(),
),
);
double zoom = 1.0 + (_kMaxZoom - 1.0) * selectedness;
return Container(
width: _kDotSpacing,
child: Center(
child: Material(
color: color,
type: MaterialType.circle,
child: Container(
width: _kDotSize * zoom,
height: _kDotSize * zoom,
child: InkWell(
onTap: () => onPageSelected(index),
),
),
),
),
);
}
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(itemCount, _buildDot),
);
}
}
class Tutorial extends StatefulWidget {
@override
State createState() => TutorialState();
}
class TutorialState extends State<Tutorial> {
final _controller = PageController(viewportFraction: 0.5);
static const _kDuration = const Duration(milliseconds: 300);
static const _kCurve = Curves.ease;
final _kArrowColor = Colors.black.withOpacity(0.8);
static onTap(index) {
print("$index selected.");
}
final List<Widget> _pages = <Widget>[
FlutterLogo(colors: Colors.blue),
FlutterLogo(style: FlutterLogoStyle.stacked, colors: Colors.red),
FlutterLogo(style: FlutterLogoStyle.horizontal, colors: Colors.green),
];
Widget _buildPageItem(BuildContext context, int index) {
return Page(page: _pages[index], idx: index);
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
PageView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _controller,
itemCount: _pages.length,
itemBuilder: (BuildContext context, int index) {
return _buildPageItem(context, index % _pages.length);
},
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.grey[800].withOpacity(0.5),
padding: const EdgeInsets.all(20.0),
child: Center(
child: DotsIndicator(
controller: _controller,
itemCount: _pages.length,
onPageSelected: (int page) {
_controller.animateToPage(
page,
duration: _kDuration,
curve: _kCurve,
);
},
),
),
),
),
],
);
}
}
class Page extends StatelessWidget {
final page;
final idx;
Page({
@required this.page,
@required this.idx,
});
onTap() {
print("${this.idx} selected.");
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0)
);
}
}
What is the error? What am I doing wrong?
flutter flutter-layout
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04
add a comment |
When I include the Tutorial class that I create inside the children of a Column class I get this error:
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 20.7s
Syncing files to device iPhone XR...
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performResize():
flutter: Horizontal viewport was given unbounded height.
flutter: Viewports expand in the cross axis to fill their container and constrain their children to match
flutter: their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
flutter: vertical space in which to expand.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1170:15)
flutter: #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
flutter: #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
flutter: #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #13 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #15 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
flutter: #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #36 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
flutter: #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #38 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #40 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #52 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
flutter: #53 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: #54 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: #55 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: #56 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
flutter: #57 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: #58 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #59 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #60 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
flutter: #62 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
flutter: #63 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
flutter: #64 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#608ab] ← Semantics ← Listener ←
flutter: _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#19222] ←
flutter: _ScrollSemantics-[GlobalKey#0390f] ← Scrollable ← NotificationListener<ScrollNotification> ←
flutter: PageView ← Stack ← ⋯
flutter: parentData: <none> (can use size)
flutter: constraints: BoxConstraints(0.0<=w<=414.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: axisDirection: right
flutter: crossAxisDirection: down
flutter: offset: _PagePosition#edc3e(offset: null, range: null..null, viewport: null, ScrollableState,
flutter: PageScrollPhysics -> AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
flutter: IdleScrollActivity#95217, ScrollDirection.idle)
flutter: anchor: 0.0
flutter: This RenderObject had the following child:
flutter: RenderSliverFillViewport#5d322 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#cca00 relayoutBoundary=up6 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#498e5 relayoutBoundary=up5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a32d0 relayoutBoundary=up4 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#cbf64 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#11d99 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#d9de7 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#554a3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#1d6d0 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#b279d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#e430d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#e8e8f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#a3175 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#4ca11 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#0d592 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#7d38e NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderOffstage#4e5b5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#4e841 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderTheatre#f534f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#85a31 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderAbsorbPointer#a08a9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#f45f1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#5dcca
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
My code is:
import 'package:flutter/material.dart';
import 'Components/Tutorial.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white,
decoration: TextDecoration.none
),
),
),
Tutorial()
],
),
);
}
}
This only happens when I insert Tutorial inside a Column. I try many things but I don't understand why the crash!
And the file with the Tutorial class:
Import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
}) : super(listenable: controller);
/// The PageController that this DotsIndicator is representing.
final PageController controller;
/// The number of items managed by the PageController
final int itemCount;
/// Called when a dot is tapped
final ValueChanged<int> onPageSelected;
/// The color of the dots.
///
/// Defaults to `Colors.white`.
final Color color;
// The base size of the dots
static const double _kDotSize = 8.0;
// The increase in the size of the selected dot
static const double _kMaxZoom = 2.0;
// The distance between the center of each dot
static const double _kDotSpacing = 25.0;
Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
0.0,
1.0 - ((controller.page ?? controller.initialPage) - index).abs(),
),
);
double zoom = 1.0 + (_kMaxZoom - 1.0) * selectedness;
return Container(
width: _kDotSpacing,
child: Center(
child: Material(
color: color,
type: MaterialType.circle,
child: Container(
width: _kDotSize * zoom,
height: _kDotSize * zoom,
child: InkWell(
onTap: () => onPageSelected(index),
),
),
),
),
);
}
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(itemCount, _buildDot),
);
}
}
class Tutorial extends StatefulWidget {
@override
State createState() => TutorialState();
}
class TutorialState extends State<Tutorial> {
final _controller = PageController(viewportFraction: 0.5);
static const _kDuration = const Duration(milliseconds: 300);
static const _kCurve = Curves.ease;
final _kArrowColor = Colors.black.withOpacity(0.8);
static onTap(index) {
print("$index selected.");
}
final List<Widget> _pages = <Widget>[
FlutterLogo(colors: Colors.blue),
FlutterLogo(style: FlutterLogoStyle.stacked, colors: Colors.red),
FlutterLogo(style: FlutterLogoStyle.horizontal, colors: Colors.green),
];
Widget _buildPageItem(BuildContext context, int index) {
return Page(page: _pages[index], idx: index);
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
PageView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _controller,
itemCount: _pages.length,
itemBuilder: (BuildContext context, int index) {
return _buildPageItem(context, index % _pages.length);
},
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.grey[800].withOpacity(0.5),
padding: const EdgeInsets.all(20.0),
child: Center(
child: DotsIndicator(
controller: _controller,
itemCount: _pages.length,
onPageSelected: (int page) {
_controller.animateToPage(
page,
duration: _kDuration,
curve: _kCurve,
);
},
),
),
),
),
],
);
}
}
class Page extends StatelessWidget {
final page;
final idx;
Page({
@required this.page,
@required this.idx,
});
onTap() {
print("${this.idx} selected.");
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0)
);
}
}
What is the error? What am I doing wrong?
flutter flutter-layout
When I include the Tutorial class that I create inside the children of a Column class I get this error:
Launching lib/main.dart on iPhone XR in debug mode...
Starting Xcode build...
Xcode build done. 20.7s
Syncing files to device iPhone XR...
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performResize():
flutter: Horizontal viewport was given unbounded height.
flutter: Viewports expand in the cross axis to fill their container and constrain their children to match
flutter: their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
flutter: vertical space in which to expand.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1170:15)
flutter: #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
flutter: #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
flutter: #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #13 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #15 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
flutter: #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #36 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
flutter: #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #38 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
flutter: #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #40 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #45 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #46 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
flutter: #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
flutter: #52 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
flutter: #53 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
flutter: #54 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
flutter: #55 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
flutter: #56 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
flutter: #57 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
flutter: #58 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #59 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
flutter: #60 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
flutter: #62 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
flutter: #63 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
flutter: #64 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#608ab] ← Semantics ← Listener ←
flutter: _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#19222] ←
flutter: _ScrollSemantics-[GlobalKey#0390f] ← Scrollable ← NotificationListener<ScrollNotification> ←
flutter: PageView ← Stack ← ⋯
flutter: parentData: <none> (can use size)
flutter: constraints: BoxConstraints(0.0<=w<=414.0, 0.0<=h<=Infinity)
flutter: size: MISSING
flutter: axisDirection: right
flutter: crossAxisDirection: down
flutter: offset: _PagePosition#edc3e(offset: null, range: null..null, viewport: null, ScrollableState,
flutter: PageScrollPhysics -> AlwaysScrollableScrollPhysics -> BouncingScrollPhysics,
flutter: IdleScrollActivity#95217, ScrollDirection.idle)
flutter: anchor: 0.0
flutter: This RenderObject had the following child:
flutter: RenderSliverFillViewport#5d322 NEEDS-LAYOUT NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-LAYOUT NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderViewport#64551 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#cca00 relayoutBoundary=up6 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#498e5 relayoutBoundary=up5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#a32d0 relayoutBoundary=up4 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#cbf64 relayoutBoundary=up3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#11d99 relayoutBoundary=up2 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#d9de7 relayoutBoundary=up1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#554a3 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#1d6d0 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#b279d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#e430d NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#e8e8f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#a3175 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#4ca11 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderFractionalTranslation#0d592 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#7d38e NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderOffstage#4e5b5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderStack#4e841 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderTheatre#f534f NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#85a31 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderAbsorbPointer#a08a9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#f45f1 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#5dcca
flutter: Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#6ed00 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#5f6ee
My code is:
import 'package:flutter/material.dart';
import 'Components/Tutorial.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white,
decoration: TextDecoration.none
),
),
),
Tutorial()
],
),
);
}
}
This only happens when I insert Tutorial inside a Column. I try many things but I don't understand why the crash!
And the file with the Tutorial class:
Import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
}) : super(listenable: controller);
/// The PageController that this DotsIndicator is representing.
final PageController controller;
/// The number of items managed by the PageController
final int itemCount;
/// Called when a dot is tapped
final ValueChanged<int> onPageSelected;
/// The color of the dots.
///
/// Defaults to `Colors.white`.
final Color color;
// The base size of the dots
static const double _kDotSize = 8.0;
// The increase in the size of the selected dot
static const double _kMaxZoom = 2.0;
// The distance between the center of each dot
static const double _kDotSpacing = 25.0;
Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
0.0,
1.0 - ((controller.page ?? controller.initialPage) - index).abs(),
),
);
double zoom = 1.0 + (_kMaxZoom - 1.0) * selectedness;
return Container(
width: _kDotSpacing,
child: Center(
child: Material(
color: color,
type: MaterialType.circle,
child: Container(
width: _kDotSize * zoom,
height: _kDotSize * zoom,
child: InkWell(
onTap: () => onPageSelected(index),
),
),
),
),
);
}
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List<Widget>.generate(itemCount, _buildDot),
);
}
}
class Tutorial extends StatefulWidget {
@override
State createState() => TutorialState();
}
class TutorialState extends State<Tutorial> {
final _controller = PageController(viewportFraction: 0.5);
static const _kDuration = const Duration(milliseconds: 300);
static const _kCurve = Curves.ease;
final _kArrowColor = Colors.black.withOpacity(0.8);
static onTap(index) {
print("$index selected.");
}
final List<Widget> _pages = <Widget>[
FlutterLogo(colors: Colors.blue),
FlutterLogo(style: FlutterLogoStyle.stacked, colors: Colors.red),
FlutterLogo(style: FlutterLogoStyle.horizontal, colors: Colors.green),
];
Widget _buildPageItem(BuildContext context, int index) {
return Page(page: _pages[index], idx: index);
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
PageView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _controller,
itemCount: _pages.length,
itemBuilder: (BuildContext context, int index) {
return _buildPageItem(context, index % _pages.length);
},
),
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: Container(
color: Colors.grey[800].withOpacity(0.5),
padding: const EdgeInsets.all(20.0),
child: Center(
child: DotsIndicator(
controller: _controller,
itemCount: _pages.length,
onPageSelected: (int page) {
_controller.animateToPage(
page,
duration: _kDuration,
curve: _kCurve,
);
},
),
),
),
),
],
);
}
}
class Page extends StatelessWidget {
final page;
final idx;
Page({
@required this.page,
@required this.idx,
});
onTap() {
print("${this.idx} selected.");
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0)
);
}
}
What is the error? What am I doing wrong?
flutter flutter-layout
flutter flutter-layout
asked Jan 2 at 23:47
user10860192user10860192
61
61
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04
add a comment |
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04
add a comment |
2 Answers
2
active
oldest
votes
try change column to listview
ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white, decoration: TextDecoration.none),
),
),
Tutorial()
],
)
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
add a comment |
you need to use Expanded for the tutorial Widget
Expanded(child: Tutorial())
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014654%2fcustom-widget-crash-when-i-insert-it-inside-a-column-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
try change column to listview
ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white, decoration: TextDecoration.none),
),
),
Tutorial()
],
)
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
add a comment |
try change column to listview
ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white, decoration: TextDecoration.none),
),
),
Tutorial()
],
)
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
add a comment |
try change column to listview
ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white, decoration: TextDecoration.none),
),
),
Tutorial()
],
)
try change column to listview
ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(38.0),
child: Text(
'Title',
style: TextStyle(
color: Colors.white, decoration: TextDecoration.none),
),
),
Tutorial()
],
)
answered Jan 3 at 0:33
hifiazhifiaz
292
292
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
add a comment |
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
I try but I get the same error :(
– user10860192
Jan 3 at 0:36
add a comment |
you need to use Expanded for the tutorial Widget
Expanded(child: Tutorial())
add a comment |
you need to use Expanded for the tutorial Widget
Expanded(child: Tutorial())
add a comment |
you need to use Expanded for the tutorial Widget
Expanded(child: Tutorial())
you need to use Expanded for the tutorial Widget
Expanded(child: Tutorial())
edited Jan 3 at 1:36
Jerome Escalante
820149
820149
answered Jan 3 at 0:35
AhmedAhmed
43137
43137
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014654%2fcustom-widget-crash-when-i-insert-it-inside-a-column-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are having a list inside row widget do you want horizontal scroll effect ??
– Ajay Beniwal
Jan 3 at 2:04