0

I am trying to create a widget that contains a SingleChildScrollView and inside that contains a column with an expanded pageview.

 Widget build(BuildContext context) {
    return Container(
      // padding: EdgeInsets.only(bottom: 90),
      color: Color(0xffF5F5F5),
      child: Column(
        children: [
          topBar(context),
          Expanded(
            child: Scaffold(
              body: SingleChildScrollView(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Container(
                      padding: EdgeInsets.only(left: 15),
                      child: TitlesPageView(
                        height: 70,
                        controller: controller,
                        hasgradient: true,
                        titles: [
                          "Geral",
                          "Endereço",
                          "Contatos",
                          "Rede Sociais",
                          "Observações",
                          "Campos Customizados",
                          "Outras Informações"
                        ],
                      ),
                    ),
                    Flexible(
                      child: PageView(
                          controller: controller,
                          children:[Geral(conta: widget.conta)]),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

But for some reason, I received this error:

======== Exception caught by rendering library =====================================================
The following NoSuchMethodError was thrown during performLayout():
The method 'toStringAsFixed' was called on null.
Receiver: null
Tried calling: toStringAsFixed(1)

The relevant error-causing widget was: 
  PageView file:///home/vitor/Documents/Codigo_Font/GetCRM/getcrm/lib/src/Bills/ui/details.dart:103:30
When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      ViewportOffset.debugFillDescription (package:flutter/src/rendering/viewport_offset.dart:248:39)
#2      ScrollPosition.debugFillDescription (package:flutter/src/widgets/scroll_position.dart:896:11)
#3      ScrollPositionWithSingleContext.debugFillDescription (package:flutter/src/widgets/scroll_position_with_single_context.dart:261:11)
#4      ViewportOffset.toString (package:flutter/src/rendering/viewport_offset.dart:233:5)
...
The following RenderObject was being processed when the exception was fired: RenderPointerListener#7148b relayoutBoundary=up19 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...  size: MISSING
...  behavior: deferToChild
...  listeners: signal
RenderObject: RenderPointerListener#7148b relayoutBoundary=up19 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  parentData: <none> (can use size)
  constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
  size: MISSING
  behavior: deferToChild
  listeners: signal
...  child: RenderSemanticsGestureHandler#4a224 relayoutBoundary=up20 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: <none> (can use size)
...    constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...    size: MISSING
...    gestures: <none>
...    child: RenderPointerListener#3445a relayoutBoundary=up21 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...      size: MISSING
...      behavior: opaque
...      listeners: down
...      child: RenderSemanticsAnnotations#f4663 relayoutBoundary=up22 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...        size: MISSING
...        child: RenderIgnorePointer#b52c5 relayoutBoundary=up23 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...          size: MISSING
...          ignoring: false
...          ignoringSemantics: false
====================================================================================================

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
RenderBox was not laid out: RenderPointerListener#7148b relayoutBoundary=up19 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

The relevant error-causing widget was: 
  PageView file:///home/vitor/Documents/Codigo_Font/GetCRM/getcrm/lib/src/Bills/ui/details.dart:103:30
When the exception was thrown, this was the stack: 
#2      RenderBox.size (package:flutter/src/rendering/box.dart:1785:12)
#3      RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:114:21)
#4      RenderObject.layout (package:flutter/src/rendering/object.dart:1777:7)
#5      RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:14)
#6      RenderObject.layout (package:flutter/src/rendering/object.dart:1777:7)
...
The following RenderObject was being processed when the exception was fired: _RenderScrollSemantics#cdbe2 relayoutBoundary=up18 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...  semantic boundary
...  size: MISSING
RenderObject: _RenderScrollSemantics#cdbe2 relayoutBoundary=up18 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  parentData: <none> (can use size)
  constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
  semantic boundary
  size: MISSING
...  child: RenderPointerListener#7148b relayoutBoundary=up19 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: <none> (can use size)
...    constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...    size: MISSING
...    behavior: deferToChild
...    listeners: signal
...    child: RenderSemanticsGestureHandler#4a224 relayoutBoundary=up20 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...      size: MISSING
...      gestures: <none>
...      child: RenderPointerListener#3445a relayoutBoundary=up21 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...        size: MISSING
...        behavior: opaque
...        listeners: down
...        child: RenderSemanticsAnnotations#f4663 relayoutBoundary=up22 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=Infinity)
...          size: MISSING
====================================================================================================

I already tried to wrap the SingleChildScrollView in a LayoutBuilder, like suggest the answer https://stackoverflow.com/a/56327933/11099584, but this won't work for me neither.

Vitor Hugo
  • 56
  • 2

1 Answers1

0

Wrap a SingleChildScrollView widget with a container with prefered size, e.g. Container(width: 300, height: 300, child: /some widget) instead of "300" you can write MediaQuery.of(context).size.width for use the device width/height.

Muhammet
  • 89
  • 6
  • Unfortunately, you answer didn't work for me, I keep receiving the errors :( And my intention is not to specify the height, I want the widget to grow according to your children. – Vitor Hugo Jun 15 '21 at 15:39