圖標組件(Icon)爲展現圖標的組件,該組件不可交互,要實現可交互的圖標,能夠考慮使用IconButton組件。
圖標組件相關的幾個組件:html
Object > Diagnosticable > DiagnosticableTree > Widget > StatelessWidget > Icon
const Icon(IconData icon, {//顯示的圖標 Key key, double size,//圖標尺寸 Color color, //圖標顏色 String semanticLabel,//語義標籤 TextDirection textDirection,//用戶呈現圖標的文本方向 })
const IconButton({ Key key, this.iconSize = 24.0, this.padding = const EdgeInsets.all(8.0), this.alignment = Alignment.center, @required this.icon, this.color, this.highlightColor, this.splashColor, this.disabledColor, @required this.onPressed, this.tooltip })
color
類型:Color
icon
類型:IconData
semanticLabel
類型:String
size
類型:double
textDirection
類型:TextDirection
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { const data = "Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep"; return MaterialApp( title: 'Hello World!', theme: ThemeData( primaryColor: Colors.red, ), home: Scaffold( appBar: AppBar( title: Text('Welcome to Fultter'), ), body: Center( child: Icon( Icons.build, color: Colors.red, semanticLabel: "user", size: 64.0, textDirection: TextDirection.rtl, ), ), ), ); } }
官方文檔--Iconapp