diff --git a/example/lib/example_listtile.dart b/example/lib/example_listtile.dart index df7c169..3af0c62 100644 --- a/example/lib/example_listtile.dart +++ b/example/lib/example_listtile.dart @@ -59,6 +59,11 @@ class _ExampleListTileState extends State { child: TextField(), ), ), + 20.hb, + ASOptionTile( + leading: '基础信息', + items: [], + ), ], ), ); diff --git a/lib/list_tile/as_option_tile.dart b/lib/list_tile/as_option_tile.dart index 99584ff..abbf602 100644 --- a/lib/list_tile/as_option_tile.dart +++ b/lib/list_tile/as_option_tile.dart @@ -14,19 +14,40 @@ class ASOptionTile extends StatelessWidget { ///内边距 final EdgeInsetsGeometry padding; + ///标题 + final dynamic leading; + ///item 推荐使用`ASOptionTileItem`,`ASVerticalTileItem`,`ASListTile` - ASOptionTile({Key key, this.items, this.item, this.padding}) + ASOptionTile({Key key, this.items, this.item, this.padding, this.leading}) : super(key: key); ///单个子组件的Tile - ASOptionTile.single({Key key, @required this.item, this.padding}) + ASOptionTile.single( + {Key key, @required this.item, this.padding, this.leading}) : items = [], super(key: key); - int get length => items.length; @override Widget build(BuildContext context) { + if (this.leading != null) { + this.items.insert( + 0, + Container( + padding: EdgeInsets.fromLTRB(10.w, 10.w, 10.w, 10.w), + alignment: Alignment.centerLeft, + child: this.leading is String + ? Text( + this.leading, + style: TextStyle( + color: kTextColor, + fontSize: 16.sp, + fontWeight: FontWeight.bold), + ) + : this.leading, + ), + ); + } return Material( color: kForegroundColor, shape: RoundedRectangleBorder(