Align的作用是為了設(shè)置子child的對(duì)齊方式,一般作為其他控件的一個(gè)參數(shù)。 構(gòu)造函數(shù)const Align({ Key key, this.alignment = Alignment.center, this.widthFactor, this.heightFactor, Widget child }) 相關(guān)屬性如下:
代碼demoimport 'package:flutter/material.dart'; void main() => runApp( MaterialApp( title: '圖標(biāo)按鈕組件示例', home: LayoutDemo(), ), ); class LayoutDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('圖標(biāo)按鈕組件示例'), ), body: Align( alignment: Alignment.centerLeft, widthFactor: 2.0, heightFactor: 2.0, //添加圖標(biāo)按鈕 child: IconButton( //圖標(biāo)元素 icon: Icon(Icons.volume_up,size: 48.0,), //按鈕提示 tooltip: '按下操作', //按下事件響應(yīng) onPressed:(){ print('按下操作'); }, ), ), ); } }
|
|