add checkbox

null_safety
小赖 4 years ago
parent 7c93fa5a3b
commit 25efdd955f

@ -0,0 +1,32 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
class ExampleBox extends StatefulWidget {
ExampleBox({Key key}) : super(key: key);
@override
_ExampleBoxState createState() => _ExampleBoxState();
}
class _ExampleBoxState extends State<ExampleBox> {
bool _state = false;
@override
Widget build(BuildContext context) {
return ASScaffold(
title: '选框',
body: ListView(
children: [
ListTile(
leading: ASCheckBox(value: _state),
title: Text('CheckBox'),
onTap: () {
setState(() {
_state = !_state;
});
},
),
],
),
);
}
}

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:example/example_bottom_button.dart';
import 'package:example/example_box.dart';
import 'package:example/example_dialog.dart';
import 'package:example/example_drawer.dart';
import 'package:example/example_listtile.dart';
@ -122,6 +123,10 @@ class _MyHomePageState extends State<MyHomePage> {
title: '刷新组件 Refresh',
onPressed: () => Get.to(ExampleRefresh()),
),
ASButton.info(
title: '选框 Box',
onPressed: () => Get.to(ExampleBox()),
),
],
),
);

@ -25,6 +25,8 @@ export 'list_tile/as_vertical_tile_item.dart';
export 'refresh/as_refresh.dart';
export 'box/as_check_box.dart';
export 'tag/as_tag.dart';
export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart';

@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASCheckBox extends StatefulWidget {
final bool value;
ASCheckBox({Key key, this.value = false}) : super(key: key);
@override
_ASCheckBoxState createState() => _ASCheckBoxState();
}
class _ASCheckBoxState extends State<ASCheckBox> {
@override
Widget build(BuildContext context) {
return Container(
height: 17.w,
width: 17.w,
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFFD5D5D5),
width: 1.w,
),
borderRadius: BorderRadius.circular(17.w),
),
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn,
height: widget.value ? 13.w : 5.w,
width: widget.value ? 13.w : 5.w,
decoration: BoxDecoration(
color: Color(0xFFF69A2D).withOpacity(widget.value ? 1 : 0),
borderRadius: BorderRadius.circular(13.w),
),
),
);
}
}
Loading…
Cancel
Save