-
-
Save Kvisaz/76c51963fa41746847c3a20baa11ddd6 to your computer and use it in GitHub Desktop.
Flutter Checkbox com label
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class AppCheckbox extends StatelessWidget { | |
final String label; | |
final bool value; | |
final ValueChanged<bool> onChanged; | |
final TextStyle labelStyle; | |
const AppCheckbox( | |
{Key key, this.label, this.value, this.onChanged, this.labelStyle}) | |
: super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return InkWell( | |
onTap: () { | |
onChanged(!value); | |
}, | |
child: Container( | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.start, | |
children: <Widget>[ | |
Checkbox( | |
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, | |
value: value, | |
onChanged: onChanged, | |
activeColor: Theme.of(context).primaryColor), | |
Text(label, style: labelStyle), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment