update checkbox

null_safety
张萌 4 years ago
parent 65c534e363
commit c6311000ae

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExampleBox extends StatefulWidget { class ExampleBox extends StatefulWidget {
ExampleBox({Key key}) : super(key: key); ExampleBox({Key key}) : super(key: key);
@ -35,6 +36,16 @@ class _ExampleBoxState extends State<ExampleBox> {
}); });
}, },
), ),
ListTile(
leading: SizedBox(width: 20.w,height: 20.w, child: ASCheckBox.checkStyle(value: _state,color: Colors.red,)),
title: Text('CheckBox'),
subtitle: Text('with redcolor'),
onTap: () {
setState(() {
_state = !_state;
});
},
),
], ],
), ),
); );

@ -3,10 +3,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASCheckBox extends StatefulWidget { class ASCheckBox extends StatefulWidget {
final bool value; final bool value;
/// ///
final bool checkStyle; final bool checkStyle;
/// ///
final Color color; final Color color;
ASCheckBox({Key key, this.value = false, this.color}) ASCheckBox({Key key, this.value = false, this.color})
: checkStyle = false, : checkStyle = false,
super(key: key); super(key: key);
@ -38,7 +40,8 @@ class _ASCheckBoxState extends State<ASCheckBox> {
height: widget.value ? 13.w : 5.w, height: widget.value ? 13.w : 5.w,
width: widget.value ? 13.w : 5.w, width: widget.value ? 13.w : 5.w,
decoration: BoxDecoration( decoration: BoxDecoration(
color:widget.color?? Color(0xFFF69A2D).withOpacity(widget.value ? 1 : 0), color: (widget.color ?? Color(0xFFF69A2D))
.withOpacity(widget.value ? 1 : 0),
borderRadius: BorderRadius.circular(13.w), borderRadius: BorderRadius.circular(13.w),
), ),
), ),
@ -58,16 +61,20 @@ class _ASCheckBoxState extends State<ASCheckBox> {
width: widget.value ? 0 : 1.w, width: widget.value ? 0 : 1.w,
), ),
borderRadius: BorderRadius.circular(27.w), borderRadius: BorderRadius.circular(27.w),
color:widget.color?? Color(0xFFFFBD32).withOpacity(widget.value ? 1 : 0), color: (widget.color ?? Color(0xFFFFBD32))
.withOpacity(widget.value ? 1 : 0),
), ),
child: AnimatedOpacity( child: AnimatedOpacity(
duration: Duration(milliseconds: 300), duration: Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
opacity: widget.value ? 1 : 0, opacity: widget.value ? 1 : 0,
child: FittedBox( child: FittedBox(
child: Padding(
padding: EdgeInsets.all(5.w),
child: Icon( child: Icon(
Icons.check, Icons.check,
size: 18.w, color: widget.color != null ? Colors.white : Colors.black,
),
), ),
), ),
), ),

Loading…
Cancel
Save