美文网首页
flutter控件之Stack

flutter控件之Stack

作者: Leo66 | 来源:发表于2018-09-11 16:17 被阅读44次
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
            ),
          )
        ],
      ),
    );
  }
}

相关文章

网友评论

      本文标题:flutter控件之Stack

      本文链接:https://www.haomeiwen.com/subject/ejmugftx.html