From 7f35b9007b3bcc2f39d54347483133239506989b Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 9 Dec 2020 10:38:52 +0800 Subject: [PATCH] update ASOptionTile --- example/lib/example_listtile.dart | 5 +++++ lib/list_tile/as_option_tile.dart | 27 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) 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(