Merge branch 'master' of 192.168.2.201:laiiihz/ansu_ui

* 'master' of 192.168.2.201:laiiihz/ansu_ui:
  add ASbutton
null_safety
小赖 4 years ago
commit 89baeb8dea

@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
body: ListView( body: ListView(
children: [ children: [
ASButton(), ASButton.gray('删除订单', (){}),
SizedBox(height: 12.w), SizedBox(height: 12.w),
TextButton( TextButton(
onPressed: () { onPressed: () {

@ -1,9 +1,69 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
/// ///
class ASButton extends StatefulWidget { class ASButton extends StatefulWidget {
ASButton({Key key}) : super(key: key); ///
ASButton.xxx({Key key}) : super(key: key); final Color color;
///
///stringwidget
final dynamic title;
///
final double radius;
///
final bool outline;
///
final Color outlineColor;
///
final Color textColor;
///
final TextStyle textStyle;
///
final EdgeInsets padding;
///
final VoidCallback onpressed;
ASButton({
Key key,
this.color,
this.radius,
this.outline = false,
this.outlineColor,
this.textColor,
this.textStyle,
this.padding,
@required this.title,
@required this.onpressed,
}) : super(key: key);
ASButton.red(this.title, this.onpressed,
{Key key, this.textStyle, this.padding, this.radius, this.color})
: outline = true,
outlineColor = Color(0xFFE50112),
textColor = Color(0xFFE50112),
super(key: key);
ASButton.gray(this.title, this.onpressed,
{Key key, this.color, this.radius, this.textStyle, this.padding})
: outline = true,
outlineColor = Color(0x73000000),
textColor = Color(0xD9000000),
super(key: key);
ASButton.yellow(this.title, this.onpressed,
{Key key, this.radius, this.outlineColor, this.textStyle, this.padding})
: color = Color(0xFFFFB600),
textColor = Color(0xD9FFFFFF),
outline = false,
super(key: key);
@override @override
_ASButtonState createState() => _ASButtonState(); _ASButtonState createState() => _ASButtonState();
@ -12,6 +72,25 @@ class ASButton extends StatefulWidget {
class _ASButtonState extends State<ASButton> { class _ASButtonState extends State<ASButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox(); return MaterialButton(
onPressed: widget.onpressed,
child: widget.title is String
? Text(
widget.title,
style: widget.textStyle == null
? TextStyle(color: widget.textColor, fontSize: 13.sp)
: widget.textStyle,
)
: widget.title,
padding: widget.padding ??
EdgeInsets.symmetric(vertical: 6.w, horizontal: 12.w),
shape: RoundedRectangleBorder(
side: widget.outline
? BorderSide(color: widget.outlineColor, width: 0.5)
: BorderSide.none,
borderRadius: BorderRadius.circular(widget.radius ?? 15.5.w)),
color: widget.color ?? Color(0xFFFFFFFF),
elevation: 0,
);
} }
} }

Loading…
Cancel
Save