flutter的布局,安卓端

 

下面代码创建了三个容器,并且使用Column的纵向布局

104、Flutter安卓端开发

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Container(
                height: 100.0,
                width: double.infinity,
                color: Colors.white,
                child: Text('Container 1'),
              ),
              SizedBox(
                height: 20.0,
              ),
              Container(
                width: double.infinity,
                height: 100.0,
                color: Colors.blue,
                child: Text('Container 2'),
              ),
              Container(
                width: double.infinity,
                height: 100.0,
                color: Colors.red,
                child: Text('Container 2'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

 

相关文章:

  • 2022-02-02
  • 2022-12-23
  • 2021-07-01
  • 2021-07-15
  • 2021-10-19
  • 2021-06-18
  • 2021-10-03
  • 2021-08-02
猜你喜欢
  • 2021-12-04
  • 2021-11-07
  • 2021-06-22
  • 2021-09-06
  • 2022-12-23
  • 2021-04-22
相关资源
相似解决方案