diff --git a/example/lib/main.dart b/example/lib/main.dart index 60c74d3..43622b5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -45,13 +45,18 @@ class _MyHomePageState extends State { ), body: ListView( children: [ - ASButton.delete('删除订单', () {}), - ASButton.info('删除订单', () {}), - ASButton.warn('删除订单', () {}), - ASButton.opration('删除订单', (){}), + ASButton.delete(title: '删除订单',onpressed: (){},), + ASButton.info(title: '删除订单',onpressed: (){},), + ASButton.warn(title: '删除订单',onpressed: (){},), + ASButton.opration(title: '删除订单',onpressed: (){},), SizedBox(height: 12.w), - ASLongButton.solid('确认', () {}), - ASLongButton.hollow('确认', () {}), + ASLongButton.solid(title: '确认',onpressed: (){},), + ASLongButton.hollow(title: '确认',onpressed: (){},), + Padding( + padding: EdgeInsets.symmetric(horizontal: 100.w), + child: ASLongButton.solid(title: 'null',onpressed:(){} ), + ), + TextButton( onPressed: () { Get.to(ExampleScaffold()); diff --git a/lib/buttons/as_button.dart b/lib/buttons/as_button.dart index e23df0e..7b0be49 100644 --- a/lib/buttons/as_button.dart +++ b/lib/buttons/as_button.dart @@ -32,6 +32,8 @@ class ASButton extends StatefulWidget { ///点击事件 final VoidCallback onpressed; + ///宽度 + final double width; ASButton({ Key key, this.bgcolor, @@ -42,31 +44,60 @@ class ASButton extends StatefulWidget { this.textStyle, this.padding, @required this.title, - @required this.onpressed, + this.onpressed, + this.width, }) : super(key: key); - ASButton.warn(this.title, this.onpressed, - {Key key, this.textStyle, this.padding, this.radius, this.bgcolor}) + ASButton.warn( + {Key key, + this.textStyle, + this.padding, + this.radius, + this.bgcolor, + this.onpressed, + @required this.title, + this.width}) : outline = true, outlineColor = Color(0xFFE50112), textColor = Color(0xFFE50112), super(key: key); - ASButton.info(this.title, this.onpressed, - {Key key, this.bgcolor, this.radius, this.textStyle, this.padding}) + ASButton.info( + {Key key, + this.bgcolor, + this.radius, + this.textStyle, + this.padding, + @required this.title, + this.onpressed, + this.width}) : outline = true, outlineColor = Color(0x73000000), textColor = Color(0xD9000000), super(key: key); - ASButton.delete(this.title, this.onpressed, - {Key key, this.radius, this.outlineColor, this.textStyle, this.padding}) + ASButton.delete( + {Key key, + this.radius, + this.outlineColor, + this.textStyle, + this.padding, + @required this.title, + this.onpressed, + this.width}) : bgcolor = Color(0xFFFFB600), textColor = Color(0xD9FFFFFF), outline = false, super(key: key); - ASButton.opration(this.title, this.onpressed, - {Key key, this.radius, this.outlineColor, this.textStyle, this.padding}) + ASButton.opration( + {Key key, + this.radius, + this.outlineColor, + this.textStyle, + this.padding, + @required this.title, + this.onpressed, + this.width}) : bgcolor = Color(0xFFF2F2F2), textColor = Color(0xD9000000), outline = false, @@ -80,6 +111,7 @@ class _ASButtonState extends State { @override Widget build(BuildContext context) { return MaterialButton( + minWidth: widget.width ?? 75.w, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: widget.onpressed, child: widget.title is String @@ -89,8 +121,7 @@ class _ASButtonState extends State { color: widget.textColor ?? Color(0xFFFFB600), fontSize: 13.sp)) : widget.title, - padding: widget.padding ?? - EdgeInsets.symmetric(vertical: 6.w, horizontal: 12.w), + padding: widget.padding ?? EdgeInsets.symmetric(vertical: 6.w), shape: RoundedRectangleBorder( side: widget.outline ? BorderSide(color: widget.outlineColor, width: 0.5.w) diff --git a/lib/buttons/as_longbutton.dart b/lib/buttons/as_longbutton.dart index 052d580..a52b8ea 100644 --- a/lib/buttons/as_longbutton.dart +++ b/lib/buttons/as_longbutton.dart @@ -31,6 +31,9 @@ class ASLongButton extends StatefulWidget { ///点击事件 final VoidCallback onpressed; + ///宽度 + final double width; + ASLongButton( {Key key, @required this.title, @@ -41,23 +44,31 @@ class ASLongButton extends StatefulWidget { this.padding, this.outline = false, this.outlineColor, - @required this.onpressed}) + this.onpressed, + this.width}) : super(key: key); - ASLongButton.solid( - this.title, - this.onpressed, { + ASLongButton.solid({ Key key, this.textStyle, this.padding, this.outlineColor, this.radius, + @required this.title, + this.onpressed, + this.width, }) : bgColor = Color(0xFFF6B72D), textColor = Color(0xFFFFFFFF), outline = false, super(key: key); - ASLongButton.hollow(this.title, this.onpressed, - {Key key, this.radius, this.textStyle, this.padding}) + ASLongButton.hollow( + {Key key, + this.radius, + this.textStyle, + this.padding, + this.onpressed, + @required this.title, + this.width}) : bgColor = Color(0xFFFFFFFF), textColor = Color(0xFFF6B72D), outline = true, @@ -71,6 +82,8 @@ class _ASLongButtonState extends State { @override Widget build(BuildContext context) { return MaterialButton( + minWidth: widget.width ?? 280.w, + disabledColor: Color(0xFFC1BDB5), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: widget.onpressed, child: widget.title is String @@ -80,8 +93,7 @@ class _ASLongButtonState extends State { color: widget.textColor ?? Color(0xFFFFFFFF), fontSize: 20.sp)) : widget.title, - padding: widget.padding ?? - EdgeInsets.symmetric(vertical: 8.w, horizontal: 112.w), + padding: widget.padding ?? EdgeInsets.symmetric(vertical: 8.w), shape: RoundedRectangleBorder( side: widget.outline ? BorderSide(color: widget.outlineColor, width: 1.w)