欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flutter入门学习--(6)容器组件Container

程序员文章站 2022-05-25 19:51:27
...

  在flutter中,我们想在一个页面中放置多个组件,就要使用Container容器组件,Container可以放置内置组件,并设置样式

padding:内边距

margin:外边距

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter',
        home: Scaffold(
          appBar: AppBar(
            title: Text("Hello World"),
          ),
          body: Center(
              child: Container(
            child: Text(
              "Hello Flutterr", 
            ),
            color: Colors.yellow,
            padding:const EdgeInsets.all(19),
            margin: EdgeInsets.fromLTRB(20, 40, 60, 180),
           
          )),
        ));
  }
}

 

相关标签: flutter