美文网首页
flutter ConstrainedBox限定宽高示例

flutter ConstrainedBox限定宽高示例

作者: 喜剧收尾_XWX | 来源:发表于2020-08-27 16:36 被阅读0次
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
        title: "ConstrainedBox限定宽高示例",
        home: Scaffold(
            appBar: AppBar(
              title: Text('ConstrainedBox限定宽高示例'),
            ),
            body: ConstrainedBox(
              constraints: BoxConstraints(
                maxWidth: 200,
                minWidth: 100,
                maxHeight: 200,
                minHeight: 100,
              ),
              child: Container(
                width: 400,
                height: 400,
                color: Colors.red,
              ),
            )));
  }
}

相关文章

网友评论

      本文标题:flutter ConstrainedBox限定宽高示例

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