简体   繁体   English

在颤动中如何仅滚动屏幕的下半部分

[英]In flutter how to scroll only bottom half of the screen

I am trying to create a UI where the upper section is an image inside clipped view and the bottom section is some text content.我正在尝试创建一个 UI,其中上半部分是裁剪视图内的图像,下半部分是一些文本内容。

I have tried Expanded and wrapped SingleChildScrolLView with Expanded Widget and I got a white screen.我已经尝试使用 Expanded Widget 展开和包装 SingleChildScrollLView 并且我得到了一个白屏。

var DetailsScreenBottomPart = SingleChildScrollView(
    child: Column(
  mainAxisSize: MainAxisSize.min,
  children: <Widget>[
    Padding(
        padding: EdgeInsets.all(18.0),
        child: Row(
          children: <Widget>[
            Text('Basic Information'),
            Spacer(),
            Text('See all')
          ],
        )),
    Container(
      padding: EdgeInsets.symmetric(horizontal: 18.0, vertical: 20.0),
      child: Text(
          'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Urna porttitor rhoncus dolor purus non enim praesent. Tristique senectus et netus et malesuada. Justo laoreet sit amet cursus sit. Nunc sed blandit libero volutpat. Donec enim diam vulputate ut pharetra sit amet. Lacus luctus accumsan tortor posuere. Mauris nunc congue nisi vitae suscipit. Commodo nulla facilisi nullam vehicula ipsum a. Fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed. Ultrices sagittis orci a scelerisque. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Consequat id porta nibh venenatis. Viverra mauris in aliquam sem fringilla ut morbi. Habitasse platea dictumst vestibulum rhoncus est pellentesque elit. Sollicitudin aliquam ultrices sagittis orci a scelerisque. Eget nunc lobortis mattis aliquam faucibus purus in massa tempor. asgdsgdsgfdsgsdfgsdgsdgsdgfsd asgsdhsdhsdh ghsh sfh sfh fsgh shg sfdh fsh sfgh j dfjsfh sfgj dfgj dfgj dfg jdfjg dfj dfjgdfj dfj dfgj d'),
    ),
  ],
));

The output i want is pretty simple but since I started flutter today, I am getting a little confused and overwhelmed by the availibility of Widgets, can I scroll the bottom half of the screen and keep the top half static?我想要的输出非常简单,但自从我今天开始颤动以来,我对 Widgets 的可用性感到有些困惑和不知所措,我可以滚动屏幕的下半部分并保持上半部分静态吗? is this even possible in flutter.这在颤振中甚至可能吗?

You need to use Column with 2 Expanded Child.您需要使用带有 2 个扩展子项的列。 Inside your second child keep the scrollable views.在你的第二个孩子里面保持可滚动视图。 eg :例如:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
          children: <Widget>[
            Expanded(
              flex: 1,
              child: Container(),
            ),
            Expanded(
              flex: 1,
              child: Container(
                width: double.infinity,
                child: SingleChildScrollView(
                  child: Column(
                    children: <Widget>[
                      Container(height: 100, child: Text("Item 1")),
                      Container(height: 100, child: Text("Item 2")),
                      Container(height: 100, child: Text("Item 3")),
                      Container(height: 100, child: Text("Item 4")),
                      Container(height: 100, child: Text("Item 5")),
                      Container(height: 100, child: Text("Item 6")),
                      Container(height: 100, child: Text("Item 7")),
                      Container(height: 100, child: Text("Item 8")),
                      Container(height: 100, child: Text("Item 9")),
                      Container(height: 100, child: Text("Item 10")),
                    ],
                  ),
                ),
              ),
            )
          ],
        ));
  }

/* Simply wrap that widget into Expanded and inside expanded a child SingleChildScrollView. /* 简单地将该小部件包装到 Expanded 中并在内部展开一个子 SingleChildScrollView。 */ */

 return Scaffold(
  body: Container(
    child: Column(
      children: <Widget>[
        //This Container will remains constant
        Container(
          height: 300,
          color: Colors.black,
        ),
        Expanded(
          child: SingleChildScrollView(
             //This is Scrollable Container
            child: Container(
              height: 400,
              color: Colors.blue,
            ),
          ),
        )
      ],
    ),
  ),
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅当用户将滚动条移动到底部时,才如何在底部保持动态滚动? - How to maintain a dynamic scroll in bottom only if the user moves it to bottom? 如何在 flutter 中将列表视图滚动到底部 - how can I scroll list view to the bottom in flutter 如何防止 iOS Safari 上屏幕底部的滚动事件 - How to prevent scroll event from the bottom of the screen on iOS Safari 如何在 Flutter Listview 中逐个滚动,逐个图像,而不显示两个半图像? - How to scroll in Flutter Listview child by child, so image by image, without having two half images shown? 滚动仅自动滚动到DIV的一半 - Scroll is auto scrolling only to half of DIV Flutter :- 如何在 Stack 视图上滚动屏幕而不缩小屏幕?(当键盘出现时滚动整个屏幕) - Flutter :- How to scroll the sceen without shrink the screen on the Stack view?(Scroll the the whole screen when the keyboard appears ) 如何自动滚动到底部,以及如何滚动到顶部(如果在底部) - How to automatically scroll to bottom, and scroll to top if at bottom Richtextbox-仅在滚动条位于底部时滚动 - Richtextbox - scroll only if scrollbar is at bottom 如何在浏览器中仅滚动顶层以覆盖底层? - How to scroll only top layer to cover over bottom layer in browser? 触摸页面顶部或底部时,滚动仅卡在 HiDpi 屏幕上 - Scroll get stuck only on HiDpi screen when touching top or bottom of the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM