繁体   English   中英

我想在黄色下方添加一个绿色框

[英]I want to add a green box below the yellow one

我想在黄色框下方添加一个绿色框。 所以请帮我在下面添加。 我大部分都完成了。 但不知道如何继续使用 rest。 我是新手,不知道该怎么做。 我只是在 Dart 中学习编码。

  runApp(
    Myapp()
  );

}

class Myapp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Container(
          height: double.infinity,
          width: 100.0,
          color: Colors.red,
        ),
        Container(
          height: 100,
          width: 100.0,
          color: Colors.yellow,
        ),
          Container(
          height: double.infinity,
          width: 100.0,
          color: Colors.blue,
        ),
          ],
        ),
        ),
      ), 
      debugShowCheckedModeBanner: false,     
    );
  }
}```

要在黄色框下方添加一个绿色框,请使用Column小部件包裹黄色框并将黄色框放在其下方。

检查下面的代码:它完美地工作:

MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Container(
          height: double.infinity,
          width: 100.0,
          color: Colors.red,
        ),
            // your column widget here
        Column(
          children: <Widget>[
            // your yellow box here
            Container(
              height: 100,
              width: 100.0,
              color: Colors.yellow,
            ),
            // your green box here
             Container(
              height: 100,
              width: 100.0,
              color: Colors.green,
            ),
          ],
        ),
          Container(
          height: double.infinity,
          width: 100.0,
          color: Colors.blue,
        ),
          ],
        ),
        ),
      ), 
      debugShowCheckedModeBanner: false,     
    );

我希望这有帮助。

我认为这个 App Brewery 的挑战,不是吗? 这里有一个提示,要在黄色下方添加一个绿色框,用列小部件包裹黄色框容器并将其添加到最近创建的列小部件中。

import 'package:flutter/material.dart';

void main() {
  runApp(Myapp());
}

class Myapp extends StatelessWidget {
  // const ({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
          child:Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[

              Container(
                height: double.infinity,
                width: 100.0,
                color: Colors.red,
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  // your yellow box here
                  Container(
                    height: 100,
                    width: 100.0,
                    color: Colors.yellow,
                  ),
                  // your green box here
                  Container(
                    height: 100,
                    width: 100.0,
                    color: Colors.green,
                  ),
                ],
              ),
              Container(
                height: double.infinity,
                width: 100.0,
                color: Colors.blue,
              ),
            ],

          ),
        ),
      ),
    );
  }
}

暂无
暂无

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

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