首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SingleChildScrollView中使用展开的页面视图

在SingleChildScrollView中使用展开的页面视图
EN

Stack Overflow用户
提问于 2021-06-15 11:51:20
回答 1查看 59关注 0票数 0

我正在尝试创建一个小部件,它包含一个SingleChildScrollView,里面包含一个带有扩展页面视图的列。

代码语言:javascript
复制
 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)]),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

但是由于某种原因,我收到了这个错误:

代码语言:javascript
复制
======== 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
====================================================================================================

我已经尝试过将SingleChildScrollView封装在LayoutBuilder中,比如建议答案为https://stackoverflow.com/a/56327933/11099584,但这对我来说也行不通。

EN

回答 1

Stack Overflow用户

发布于 2021-06-15 12:27:49

用首选大小的容器包装一个SingleChildScrollView小部件,例如Container(width: 300, height: 300, child: /some widget)而不是"300“你可以写MediaQuery.of(context).size.width来使用设备的宽度/高度。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67979778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档