颤振滚动视图

时间:2020-10-22 02:17:35

标签: flutter web flutter-layout flutter-web

我在使我的Web应用程序的一部分可滚动时遇到问题。我尝试了多种解决方案,但没有任何效果。有什么想法吗?

Flexible(
          flex: 3,
          child: Align(
            alignment: Alignment.topRight,
            child: Padding(
              padding: const EdgeInsets.fromLTRB(20, 20, 0, 0),
              child: Column(
                children: [
                  Align(
                    alignment: Alignment.topLeft,
                    child: Text(
                        'Stories',
                        style: TextStyle(
                            color: Palette.white,
                            fontWeight: FontWeight.bold,
                            fontSize: 16
                        )
                    ),
                  ),
                  Stories(
                    currentUser: currentUser,
                    stories: stories,
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(0, 20, 0, 20),
                    child: RecommendedCards(),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerLeft,
                      child: RecommendedFollowingList(
                          users: recommendedFollow
                      ),
                    )
                  ),
                  PolicyView()
                ],
              ),
            ),
          ),
        ),

这是我的代码,使我无法滚动。尝试添加SingleChildScrollView时,我一直收到错误消息。那说以下

在此RenderBox上调用hitTest()方法:_RenderScrollSemantics#0e2ee relayoutBoundary = up10: 需要合成 创建者:_ScrollSemantics- [GlobalKey#1a713]←可滚动←PrimaryScrollController←SingleChildScrollView←对齐←灵活←行←DesktopScreen←LayoutBuilder←响应←__BodyBuilder←MediaQuery←⋯ parentData:offset = Offset(0.0,0.0)(可以使用大小) 约束:BoxConstraints(0.0 <= w <= 332.0,0.0 <= h <= 621.0) 语义边界 尺寸:MISSING 尽管未将该节点标记为需要布局,但未设置其大小。 RenderBox对象必须具有明确的大小,然后才能进行命中测试。确保有问题的RenderBox在布局期间设置其大小。 << / p>

下面是视图的完整代码。

class DesktopScreen extends StatelessWidget {
  final TrackingScrollController scrollController;

  const DesktopScreen({
    Key key,
    @required this.scrollController,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Flexible(
          flex: 3,
          child: Align(
            alignment: Alignment.centerLeft,
            child: Padding(
              padding: const EdgeInsets.all(12.0),
              child: ContactsList(users: onlineUsers,
              ),
            ),
          ),
        ),
        Container(
          width: 600.0,
          child: CustomScrollView(
            controller: scrollController,
            slivers: [
              SliverToBoxAdapter(
                child: Padding(
                  padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
                  child: CreatePostContainer(currentUser: currentUser),
                ),
              ),
              SliverList(
                delegate: SliverChildBuilderDelegate(
                      (context, index) {
                    final Post post = posts[index];
                    return PostContainer(post: post);
                  },
                  childCount: posts.length,
                ),
              ),
            ],
          ),
        ),
        Flexible(
          flex: 3,
          child: Align(
            alignment: Alignment.topRight,
            child: SingleChildScrollView(
              child: Padding(
                padding: const EdgeInsets.fromLTRB(20, 20, 0, 0),
                child: Column(
                  children: [
                    Align(
                      alignment: Alignment.topLeft,
                      child: Text(
                          'Stories',
                          style: TextStyle(
                              color: Palette.white,
                              fontWeight: FontWeight.bold,
                              fontSize: 16
                          )
                      ),
                    ),
                    Stories(
                      currentUser: currentUser,
                      stories: stories,
                    ),
                    Padding(
                      padding: const EdgeInsets.fromLTRB(0, 20, 0, 20),
                      child: RecommendedCards(),
                    ),
                    Expanded(
                      child: Align(
                        alignment: Alignment.centerLeft,
                        child: RecommendedFollowingList(
                            users: recommendedFollow
                        ),
                      )
                    ),
                    PolicyView()
                  ],
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}

2 个答案:

答案 0 :(得分:0)

您可以使用SingleChildScrollView`包装小部件。

一个可以滚动单个小部件的框。

答案 1 :(得分:0)

这非常简单,用SingleChildScrollview包装您的主窗口小部件。

$rules  = [
            'qty'       => 'required',

        ];
$message = [
           
            'qty.required' => 'This field is Required',
        ];
$validator = Validator::make($request->all(), $rules,$message);