import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import '../constants.dart'; class CheckInputContainer extends StatefulWidget { final bool? isChecked; final IconData? icon; final String label; final ValueChanged onChanged; final double fontSize; const CheckInputContainer({ Key? key, this.isChecked, this.icon, required this.label, required this.onChanged, this.fontSize = 20 }) : super(key: key); @override _CheckInputContainerState createState() => _CheckInputContainerState(); } class _CheckInputContainerState extends State { bool? isChecked; @override void initState() { setState(() { isChecked = widget.isChecked; }); super.initState(); } @override Widget build(BuildContext context) { return Container( child: Row( children: [ Align( alignment: AlignmentDirectional.centerStart, child: Row( children: [ if(widget.icon != null) Padding( padding: const EdgeInsets.only(right: 8.0), child: Icon( widget.icon, color: kMainColor, size: 25.0, ), ), if(widget.label != null) AutoSizeText( widget.label, style: new TextStyle(fontSize: widget.fontSize, fontWeight: FontWeight.w300), maxLines: 2, maxFontSize: widget.fontSize, textAlign: TextAlign.center, ), ], ) ), Padding( padding: const EdgeInsets.all(10.0), child: Container( width: 50, height: 50, child: Checkbox( shape: CircleBorder(), value: isChecked, checkColor: Colors.white, activeColor: kMainColor, onChanged: (bool? value) { setState(() { isChecked = value; }); widget.onChanged(value!); }, ), ), ), ], ), ); } }