繁体   English   中英

设置孩子的透明颜色以在 Flutter 中重新创建此布局

[英]Set transparent color of a child to recreate this layout in Flutter

我目前正在学习一门需要重新创建此布局的课程:布局设计

我正在努力在脚手架中心的第二个盒子上设置透明的黄色。 这是我的代码:

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(scaffoldBackgroundColor: Colors.teal),
      home: Scaffold(
        body: SafeArea(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Container(
                color: Colors.red,
                height: double.infinity,
                width: 100.0,
              ),
              Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      color: Colors.yellow,
                      height: 100.0,
                      width: 100.0,
                    ),
                    Container(
                      width: 100.0,
                      height: 100.0,
                      color: Colors.yellowAccent,
                    )
                  ]),
              Container(
                color: Colors.blue,
                height: double.infinity,
                width: 100.0,
              )
            ],
          ),
        ),
      ),
    );
  }
}

感谢您的帮助。

只需与Colors.yellow.withOpacity(0.3)用于第二个框

在此处输入图片说明

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(scaffoldBackgroundColor: Colors.teal),
      home: Scaffold(
        body: SafeArea(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Container(
                color: Colors.red,
                height: double.infinity,
                width: 100.0,
              ),
              Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      color: Colors.yellow,
                      height: 100.0,
                      width: 100.0,
                    ),
                    Container(
                      width: 100.0,
                      height: 100.0,
                      color: Colors.yellow.withOpacity(0.3),
                    )
                  ]),
              Container(
                color: Colors.blue,
                height: double.infinity,
                width: 100.0,
              )
            ],
          ),
        ),
      ),
    );
  }
}

暂无
暂无

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

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