flutter控件之Stack

2018-09-11  本文已影响44人  Leo66
import 'package:flutter/material.dart';
class LearnStack extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return new _LearnStack();
  }
}
class _LearnStack extends State<LearnStack>{
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Stack(
        alignment: AlignmentDirectional.center,//内容对齐方式
        fit: StackFit.loose,
        children: <Widget>[
          new Container(
            width: 150.0,
            height: 100.0,
            decoration: new BoxDecoration(
              color: Colors.blue
            ),
          ),
          new Container(
            width: 120.0,
            height: 80.0,
            decoration: new BoxDecoration(
                color: Colors.red
            ),
          )
        ],
      ),
    );
  }
}
上一篇 下一篇

猜你喜欢

热点阅读