Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical viewpoint given unbounded height . #25733

Closed
nateshmbhat opened this issue Dec 24, 2018 · 10 comments
Closed

Vertical viewpoint given unbounded height . #25733

nateshmbhat opened this issue Dec 24, 2018 · 10 comments

Comments

@nateshmbhat
Copy link

nateshmbhat commented Dec 24, 2018

The following code shows the errors in the log and only outputs an appbar on the screen .

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class AchievementsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(title: Text('Achievements',),),
      body: Container(
          padding: EdgeInsets.all(20),
          alignment: Alignment(0, 0),
          child: Container(
            child: Column(
              children: <Widget>[
                Achievement() ,
              ] ,
            ),
          )
          )
      );
  }
}


class Achievement extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        child: StreamBuilder<QuerySnapshot>(
          stream: Firestore.instance.collection('achievements').snapshots(),
          builder: (BuildContext context,
              AsyncSnapshot<QuerySnapshot> snapshot) {
            if (snapshot.hasError) {
              print(snapshot.error);
              return Text("Error : ${snapshot.error}");
            }

            switch (snapshot.connectionState) {
              case ConnectionState.waiting :
                return Text("Loading...");
              default :
                return ListView(
                  children: snapshot.data.documents.map((
                      DocumentSnapshot document) {
                    return ListTile(
                      title: Text(document['title']),
                      subtitle: Text(document['description']),
                      enabled: true,
                      isThreeLine: true,
                      contentPadding: EdgeInsets.all(2),
                    );
                  }).toList(),
                );
            }
          },
        )
    );
  }
}

Logs

Performing hot reload...
Syncing files to device Android SDK built for x86...
I/flutter (12007): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (12007): The following assertion was thrown during performResize():
I/flutter (12007): Vertical viewport was given unbounded height.
I/flutter (12007): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter (12007): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (12007): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (12007): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (12007): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (12007): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (12007): the height of the viewport to the sum of the heights of its children.
I/flutter (12007): 
I/flutter (12007): When the exception was thrown, this was the stack:
I/flutter (12007): #0      RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1129:15)
I/flutter (12007): #1      RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
I/flutter (12007): #2      RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
I/flutter (12007): #3      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #4      RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #5      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #6      RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #7      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #8      RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #9      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #10     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #11     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #12     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #13     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #14     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #15     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #16     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #17     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (12007): #18     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #19     RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (12007): #20     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #21     RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:385:13)
I/flutter (12007): #22     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #23     RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
I/flutter (12007): #24     RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (12007): #25     MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (12007): #26     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (12007): #27     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (12007): #28     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (12007): #29     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (12007): #30     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (12007): #31     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (12007): #32     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (12007): #33     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (12007): #34     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (12007): #35     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (12007): #36     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (12007): #37     _invoke (dart:ui/hooks.dart:154:13)
I/flutter (12007): #38     _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (12007): 
I/flutter (12007): The following RenderObject was being processed when the exception was fired:
I/flutter (12007):   RenderViewport#f6e2a NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12007):   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#d55b3] ← Semantics ← Listener ←
I/flutter (12007):   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2c607] ←
I/flutter (12007):   _ScrollSemantics-[GlobalKey#a8f1d] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (12007):   NotificationListener<ScrollNotification> ← ⋯
I/flutter (12007):   parentData: <none> (can use size)
I/flutter (12007):   constraints: BoxConstraints(0.0<=w<=371.4, 0.0<=h<=Infinity)
I/flutter (12007):   size: MISSING
I/flutter (12007):   axisDirection: down
I/flutter (12007):   crossAxisDirection: right
I/flutter (12007):   offset: ScrollPositionWithSingleContext#05b6a(offset: 0.0, range: null..null, viewport: null,
I/flutter (12007):   ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#e7185,
I/flutter (12007):   ScrollDirection.idle)
I/flutter (12007):   anchor: 0.0
I/flutter (12007): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (12007):   RenderSliverPadding#d9447 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12007):     RenderSliverList#9a7ce NEEDS-LAYOUT NEEDS-PAINT
I/flutter (12007): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderViewport#f6e2a NEEDS-LAYOUT NEEDS-PAINT
Reloaded 2 of 423 libraries in 309ms.
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderViewport#f6e2a NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#7bed0 relayoutBoundary=up11 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#6b664 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#e4ae2 relayoutBoundary=up9 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#982da relayoutBoundary=up8 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#dd3f9 relayoutBoundary=up7 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#81f3d relayoutBoundary=up6 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#63249 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#bb42d relayoutBoundary=up4 NEEDS-PAINT
I/flutter (12007): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#bb42d relayoutBoundary=up4 NEEDS-PAINT

info • This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final) • lib/main.dart:46:7 • must_be_immutable

✓] Flutter (Channel beta, v1.0.0, on Linux, locale en_US.UTF-8)
    • Flutter version 1.0.0 at /home/natesh/Applications/flutter
    • Framework revision 5391447fae (4 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/natesh/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/natesh/Applications/android-studio/jre/bin/java
    • Java version openjdk version "1.8.0_152-release"
    • All Android licenses accepted.

[✓] Android Studio (version 3.2)
    • Android Studio at /home/natesh/Applications/android-studio
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version openjdk version "1.8.0_152-release"

[✓] VS Code (version 1.30.1)
    • VS Code at /usr/share/code
    • Flutter extension version 2.21.1

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!
@nateshmbhat
Copy link
Author

nateshmbhat commented Dec 25, 2018

Error can be solved by giving shrinkWrap : true for ListView
OR
Wrapping ListView inside a container which has a fixed Height

@bhanuka96
Copy link

bhanuka96 commented Feb 8, 2019

adding this two lines

 ListView.builder(
            scrollDirection: Axis.vertical,
            shrinkWrap: true,

@MechaGirls
Copy link

@bhanuka96 why?

@hasen6
Copy link

hasen6 commented Nov 22, 2019

Error can be solved by giving shrinkWrap : true for ListView
OR
Wrapping ListView inside a container which has a fixed Height

These are not usable solutions. shrinkWrap : true disables scrolling on the listview defeating the point of using listview in the first place. Giving a fixed height works but is not an acceptable solution since there is no reason listview can't be dynamic.

@devibrahimkarahan
Copy link

Error can be solved by giving shrinkWrap : true for ListView
OR
Wrapping ListView inside a container which has a fixed Height

These are not usable solutions. shrinkWrap : true disables scrolling on the listview defeating the point of using listview in the first place. Giving a fixed height works but is not an acceptable solution since there is no reason listview can't be dynamic.

Try shrinkWrap: true with physics: ScrollPhysics() for scrolling

@IvansPhoto
Copy link

physics: ScrollPhysics() for scrolling

The most useful comment on this question in whole internet!

@Hadii1
Copy link

Hadii1 commented Feb 8, 2020

"Shrink wrapping the content of the scroll view is significantly more expensive than expanding to the maximum allowed size because the content can expand and contract during scrolling, which means the size of the scroll view needs to be recomputed whenever the scroll position changes" from the docs

@jasprit
Copy link

jasprit commented Apr 19, 2020

adding this two lines

 ListView.builder(
            scrollDirection: Axis.vertical,
            shrinkWrap: true,

it works but till some fixed height

@bhanuka96
Copy link

adding this two lines

 ListView.builder(
            scrollDirection: Axis.vertical,
            shrinkWrap: true,

it works but till some fixed height

Warp on Expanded or Flexible widget

@lock
Copy link

lock bot commented May 6, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants