简体   繁体   English

我怎样才能在 flutter 中制作这个堆栈小部件?

[英]how can I make this stack widget in flutter?

I'm working on an application, and I need to know how to make this widget,我正在开发一个应用程序,我需要知道如何制作这个小部件,

小部件

I need to put a container over the image I try to use stack widget but I have some bugs can you help?我需要在图像上放置一个容器 我尝试使用堆栈小部件但是我有一些错误你能帮忙吗?

by default stack widget childs are positioned on the top left corner of the screen.默认情况下,堆栈小部件的子元素位于屏幕的左上角。 first child is on the bottom of the stack and anything comes after it is going to be above it.第一个孩子在堆栈的底部,任何在它之后的东西都会在它上面。 the solution is simple use Positioned widget to position the stack child widgets anywhere you want on the screen.解决方案很简单,使用 Positioned 小部件到 position 在屏幕上任何您想要的位置堆叠子小部件。 this code should do the trick for you.这段代码应该可以为您解决问题。 I dont know if its the best approach for your case but it works我不知道它是否适合您的情况,但它有效

Stack(
        fit: StackFit.expand,
        children: [
          Container(
            width: double.infinity,
            height: 220,
            color: Colors.indigo,
            child: const Text(
              'consider this is an Image',
              textAlign: TextAlign.center,
            ),
          ),
          Positioned(
            top: 180,
            width: 395,
            child: Container(
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topRight: Radius.circular(32),
                  topLeft: Radius.circular(32),
                ),
              ),
              height: 600,
              width: 395,
              child: Column(
                children: const [
                  // ** Your child widgets**
                ],
              ),
            ),
          ),
        ],
      ),

You can use stack for overlapping each other and than inside that stack you can use DraggableScrollableSheet class for that scrollable white card.您可以使用stack相互重叠,而不是在该堆栈内部您可以使用DraggableScrollableSheet class作为scrollable white卡。

Stack(
        fit: StackFit.expand,
        children: [
          Container(
               Image(),
          ),
           DraggableScrollableSheet(
          builder: (BuildContext context, ScrollController scrollController){
                 return Container(),
              
                }
              ),
            
          ),
        ],
      ),

Here is the link for more Here这是更多的链接在这里

You can try something like this你可以尝试这样的事情

Stack(
      children: <Widget>[
        Container(
          child: Image.asset(url),
          ),
        ),
        Container(
          child: Text('Show text here')
        ),
]),

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

相关问题 如何使Stack小部件中的第二个小部件很重要? - How can I make second widget in Stack widget is important? 如何让 Positioned 小部件在 Stack (flutter) 中工作? - How can I get the Positioned widget to work in a Stack (flutter)? 如何在 flutter 中的堆栈后面制作可点击的小部件 - How to make clickable widget behind stack in flutter Flutter 布局:如何在 Flutter 的 Flex(或另一行)中放置一行? 还使用 Stack 小部件 - Flutter Layout: How can I put a Row inside a Flex (or another Row) in Flutter? Also using Stack widget 如何在 Flutter Scaffold 小部件中使整个正文成为 textField? - How can I make the entire body a textField in a Flutter Scaffold widget? 如何在 Flutter 中使用像“for”这样的迭代器制作 Widget? - How can I make Widget using iterator like 'for' in Flutter? 如何在flutter中的任何小部件周围制作渐变阴影? - How can I make a gradient shadow around any widget in flutter? 如何使这个下拉按钮小部件在 Flutter 中可重用? - How Can I Make This Dropdown Button Widget Reusable Iin Flutter? 如何在文本小部件中的 flutter 中制作段落? - How can I make paragraphs in flutter in a text widget? 在 Flutter 中,如何使用 WebView 制作一个简单的浏览器小部件? - In Flutter, how can I make a simple Browser widget with a WebView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM