Flutter基础(三)

2020-05-28  本文已影响0人  Mr_不靠谱_先森

布局

child: Align(
                alignment: Alignment.topLeft,
                child: Text(
                  "hello container",
                  style: TextStyle(fontSize: 30, color: Colors.black),
                )),
child: Stack(
        children: <Widget>[
          Image(
            image: NetworkImage(
                "https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white-d0c9fe2af5.png"),
          ),
          Positioned(
            top: 20,
            right: 20,
            child: Image.network(
              "https://ossweb-img.qq.com/upload/adw/image/20191022/627bdf586e0de8a29d5a48b86700a790.jpeg",
              width: 100.0,
              height: 100.0,
            ),
          )
        ],
      )),
import 'package:flutter/material.dart';

class FlexPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("flex page"),
      ),
      body: Flex(
        direction: Axis.horizontal,
        children: <Widget>[
          Container(
            width: 300,
            height: 100,
            color: Colors.red,
          ),
          Expanded(
            flex: 1,
            child: Container(
              height: 100.0,
              color: Colors.blue,
            ),
          ),
          Expanded(
            flex: 1,
            child: Container(
              height: 100.0,
              color: Colors.green,
            ),
          ),
        ],
      ),
    );
  }
}
上一篇下一篇

猜你喜欢

热点阅读