import 'package:flutter/material.dart'; class IconExtensionDemo extends StatelessWidget { @override Widget build(BuildContext context) { // Icon字体图标和图片图标 // 1.字体图标矢量图(放大的时候不会失真) // 2.字体图标可以设置颜色 // 3.图标很多时, 占据空间更小 // return Icon(Icons.pets, size: 300, color: Colors.orange,); // return Icon(IconData(0xe91d, fontFamily: 'MaterialIcons'), size: 300, color: Colors.orange,); // 1.0xe91d -> unicode编码 // 2.设置对应的字体 return Text("\ue91d", style: TextStyle(fontSize: 100, color: Colors.orange, fontFamily: "MaterialIcons"),); } } class ImageExtensionDemo extends StatelessWidget { const ImageExtensionDemo({ Key key, @required this.imageURL, }) : super(key: key); final String imageURL; @override Widget build(BuildContext context) { // 1.占位图的问题: FadeInImage // 2.图片缓存: 1000张 100m return FadeInImage( fadeOutDuration: Duration(milliseconds: 1), fadeInDuration: Duration(milliseconds: 1), placeholder: AssetImage("assets/images/juren.jpeg"), image: NetworkImage(imageURL), ); } } class ButtonExtensionDemo extends StatelessWidget { const ButtonExtensionDemo({ Key key, }) : super(key: key); @override Widget build(BuildContext context) { // 1.默认情况下Button上下有一定的间距 // 2.Button变小: ButtonTheme // 3.取出Button的内边距 return Column( children: <Widget>[ ButtonTheme( minWidth: 30, height: 10, child: FlatButton( padding: EdgeInsets.all(0), color: Colors.red, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, child: Text("Flat Button1"), textColor: Colors.white, onPressed: () {}, ), ) ], ); } }
MaterialTapTargetSize enum
padded → const MaterialTapTargetSize
Expands the minimum tap target size to 48px by 48px. 最小可点击区域为48
This is the default value of ThemeData.materialTapTargetSize and the recommended size to conform to Android accessibility scanner recommendations.
MaterialTapTargetSize()
shrinkWrap → const MaterialTapTargetSize 包裹内容
Shrinks the tap target size to the minimum provided by the Material specification.
MaterialTapTargetSize()