Flutter 容器(5) - SizedBox


SizedBox: 兩種用法:一是可用來設置兩個widget之間的間距,二是可以用來限制子組件的大小。

import 'package:flutter/material.dart';

class AuthList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('代碼測試'),
        centerTitle: true,
      ),
      body: Row(children: <Widget>[
        SizedBox(
          width: 150.0,
          height: 150.0,
          child: Container(
            margin: EdgeInsets.all(20.0),
            width: 200.0,
            height: 200.0,
            color: Colors.blue,
          ),
        ),
        SizedBox(
          width: 100.0,
          height: 100.0,
          child: Container(
            margin: EdgeInsets.all(20.0),
            width: 200.0,
            height: 200.0,
            color: Colors.yellow,
          ),
        ),
        SizedBox(

          width: 100.0,
          height: 100.0,
          child: Container(
            margin: EdgeInsets.all(20.0),
            width: 200.0,
            height: 200.0,
            color: Colors.red,
          ),
        )
      ]) ,
    );
  }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM