Align的做用是爲了設置子child的對齊方式,通常做爲其餘控件的一個參數。app
const Align({ Key key, this.alignment = Alignment.center, this.widthFactor, this.heightFactor, Widget child })
相關屬性以下:less
import 'package:flutter/material.dart'; void main() => runApp( MaterialApp( title: '圖標按鈕組件示例', home: LayoutDemo(), ), ); class LayoutDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('圖標按鈕組件示例'), ), body: Align( alignment: Alignment.centerLeft, widthFactor: 2.0, heightFactor: 2.0, //添加圖標按鈕 child: IconButton( //圖標元素 icon: Icon(Icons.volume_up,size: 48.0,), //按鈕提示 tooltip: '按下操做', //按下事件響應 onPressed:(){ print('按下操做'); }, ), ), ); } }