简体   繁体   English

如何在颤动中制作滚动视图?

[英]How to make scrollview in flutter?

I am making a flutter application in which i need to make a design like in the image我正在制作一个颤振应用程序,我需要在其中进行图像设计

Now what i am doing is that i made a stack widget as main and then using Positioned widget i positined that back button.Now the remaining view of screen should be inside scrollview so i used SingleChildScrollView for that but as that was from top from screen i added top margin to it by putting SingleChildScrollView inside container but that does not make view Scrollable.I am new to the flutter development Please provide me some help in code to make the layout like given in image现在我正在做的是我制作了一个堆栈小部件作为主要然后使用定位小部件我定位了后退按钮。现在屏幕的剩余视图应该在滚动视图内,所以我使用了 SingleChildScrollView 但因为那是从屏幕顶部开始的我通过将 SingleChildScrollView 放在容器内为它添加了顶部边距,但这不会使视图可滚动。

https://i.imgur.com/hL8zvXr.jpg https://i.imgur.com/hL8zvXr.jpg

Try to create a layout that gives you a widget tree similar to this:尝试创建一个布局,为您提供类似于此的小部件树:

Column
  Row
    CloseButton
  Text
  GridView
    Card
      Text
  Row
    Column
      Container
        Icon
      Text

Remember to set the mainAxisAlignment property on the Rows and Columns, to properly align the widgets.请记住在 Rows 和 Columns 上设置 mainAxisAlignment 属性,以正确对齐小部件。 Also look into decorations on the Container.还要查看容器上的装饰。

In addition if you want the background to have a gradient you can achieve that by wrapping the entire thing in a Container and adding a BoxDecoration with a gradient to the Container's decoration property.此外,如果您希望背景具有渐变效果,您可以通过将整个事物包装在 Container 中并为 Container 的装饰属性添加带有渐变效果的 BoxDecoration 来实现。

This is only a hint for you, but hopefully it will get you started.这只是给你的一个提示,但希望它能让你开始。

For this kind of menu, you can also create a silvergrid inside a CustomScrollView :对于这种菜单,您还可以在 CustomScrollView 中创建一个 silvergrid:

CustomScrollView(
    primary: false,
    slivers: <Widget>[
      SliverPadding(
        padding: const EdgeInsets.all(3.0),
        sliver: SliverGrid.count(
          mainAxisSpacing: 1, //horizontal space
          crossAxisSpacing: 1, //vertical space
          crossAxisCount: 2, //number of items a row
          children: <Widget>[
            MenuButton('dashboard', 'Manager', FontAwesomeIcons.tasks),
            MenuButton('supervisor', 'Supervisor', FontAwesomeIcons.mailchimp),
            MenuButton('ganttBoard', 'Project', FontAwesomeIcons.folder),
            MenuButton('manager', 'Calendar', FontAwesomeIcons.calendar),
            MenuButton('manager', 'BIM', FontAwesomeIcons.sign),
            MenuButton('manager', 'Notes', FontAwesomeIcons.stickyNote),
            MenuButton('manager', 'Documents', FontAwesomeIcons.dochub),
            MenuButton('manager', 'Assigments', FontAwesomeIcons.checkSquare)
          ],
        ),
      ),
    ],
  ),

You can put a List as children instead of these buttons您可以将列表作为子项而不是这些按钮

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM