From f2aceb5c55c4914b58e707ca149e04f41bd6148e Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 5 Aug 2021 19:12:07 +0800 Subject: [PATCH] update button update check tag --- example/lib/widgets/example_tag.dart | 2 +- lib/buttons/as_long_button.dart | 8 ++++---- lib/tag/as_check_tag.dart | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/example/lib/widgets/example_tag.dart b/example/lib/widgets/example_tag.dart index a861eb9..ea6800e 100644 --- a/example/lib/widgets/example_tag.dart +++ b/example/lib/widgets/example_tag.dart @@ -64,7 +64,7 @@ class _ExampaleTagState extends State { ), ListTile( onTap: () => setState(() => _checked = !_checked), - title: Text('ASCheckedTag'), + title: Text('ASCheckTag'), trailing: ASCheckTag( checked: _checked, text: 'TAG'.text.make(), diff --git a/lib/buttons/as_long_button.dart b/lib/buttons/as_long_button.dart index 3360029..261e61a 100644 --- a/lib/buttons/as_long_button.dart +++ b/lib/buttons/as_long_button.dart @@ -21,7 +21,7 @@ class ASLongButton extends StatelessWidget { final TextStyle? textStyle; ///内边距 - final Padding? padding; + final EdgeInsetsGeometry? padding; ///是否有边框 final bool outline; @@ -98,10 +98,10 @@ class ASLongButton extends StatelessWidget { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: onPressed, child: title is String - ? Text(title, - style: textStyle ?? TextStyle(fontSize: 20.sp)) + ? Text(title, style: textStyle ?? TextStyle(fontSize: 20.sp)) : title, - padding: padding as EdgeInsetsGeometry? ?? EdgeInsets.symmetric(vertical: 8.w), + padding: + padding as EdgeInsetsGeometry? ?? EdgeInsets.symmetric(vertical: 8.w), shape: RoundedRectangleBorder( side: outline ? BorderSide(color: outlineColor!, width: 1.w) diff --git a/lib/tag/as_check_tag.dart b/lib/tag/as_check_tag.dart index 8cf3ce7..b1b30ee 100644 --- a/lib/tag/as_check_tag.dart +++ b/lib/tag/as_check_tag.dart @@ -5,11 +5,11 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; class ASCheckTag extends StatelessWidget { final bool checked; - final Widget text; + final Widget? text; const ASCheckTag({ Key? key, this.checked = false, - required this.text, + this.text, }) : super(key: key); @override @@ -39,15 +39,16 @@ class ASCheckTag extends StatelessWidget { ), ), ), - 6.wb, - AnimatedDefaultTextStyle( - duration: Duration(milliseconds: 300), - curve: Curves.easeInOutCubic, - style: TextStyle( - color: checked ? Color(0xFF00BF44) : Color(0xFFFF0000), + if (text != null) 6.wb, + if (text != null) + AnimatedDefaultTextStyle( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + style: TextStyle( + color: checked ? Color(0xFF00BF44) : Color(0xFFFF0000), + ), + child: text!, ), - child: text, - ), ], ); }