Created
January 29, 2019 20:51
-
-
Save marcusedu/9d53751f3a382805e6f4bc302b260cd4 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
Here is an updated version for Dart 3.