diff --git a/lib/list_tile/as_option_tile.dart b/lib/list_tile/as_option_tile.dart index b742d45..13f98b6 100644 --- a/lib/list_tile/as_option_tile.dart +++ b/lib/list_tile/as_option_tile.dart @@ -31,29 +31,30 @@ class ASOptionTile extends StatelessWidget { int get length => items!.length; + List get _widgets => leading == null + ? (items ?? []) + : [ + Container( + alignment: Alignment.centerLeft, + child: this.leading is String + ? Padding( + padding: + EdgeInsets.symmetric(vertical: 14.w, horizontal: 10.w), + child: Text( + this.leading, + style: TextStyle( + color: kTextColor, + fontSize: 16.sp, + fontWeight: FontWeight.bold), + ), + ) + : this.leading, + ), + ...(items ?? []), + ]; + @override Widget build(BuildContext context) { - if (this.leading != null) { - this.items!.insert( - 0, - Container( - alignment: Alignment.centerLeft, - child: this.leading is String - ? Padding( - padding: EdgeInsets.symmetric( - vertical: 14.w, horizontal: 10.w), - child: Text( - this.leading, - style: TextStyle( - color: kTextColor, - fontSize: 16.sp, - fontWeight: FontWeight.bold), - ), - ) - : this.leading, - ), - ); - } return Material( clipBehavior: Clip.antiAlias, color: kForegroundColor,