123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import 'package:flutter/material.dart';
- import 'package:ftrecruiter/comm/widget/common_widget.dart';
- //CheckBox控件封装
- class AppCheckbox extends StatefulWidget {
- final String? label;
- final bool? checked;
- final Function(bool?)? onChecked;
- AppCheckbox({this.label, this.checked, this.onChecked});
- @override
- _AppCheckboxState createState() => _AppCheckboxState();
- }
- class _AppCheckboxState extends State<AppCheckbox> {
- bool? _checked = false;
- void _onChecked(bool? checked) {
- print(checked);
- setState(() {
- _checked = checked;
- });
- if (widget.onChecked != null) {
- widget.onChecked!(checked);
- }
- }
- @override
- Widget build(BuildContext context) {
- return SafeArea(
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(
- width: 24.0,
- height: 24.0,
- child: Checkbox(
- value: _checked,
- materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
- onChanged: _onChecked),
- ),
- CommonWidget.rowWidth(width: 10.0),
- Flexible(
- child: Text(
- widget.label!,
- textAlign: TextAlign.left,
- style: const TextStyle(
- fontSize: 13.0,
- color: Colors.white,
- ),
- ),
- ),
- ],
- ),
- );
- }
- }
|