-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♿ Settings checkbox and switch accessibility improved
- Loading branch information
1 parent
d021e12
commit 888c05e
Showing
8 changed files
with
99 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomCheckBox extends StatefulWidget { | ||
final bool isChecked; | ||
final bool visibleSwitch; | ||
CustomCheckBox({Key key, this.isChecked, this.visibleSwitch}) | ||
: super(key: key); | ||
|
||
@override | ||
_CustomCheckBoxState createState() => _CustomCheckBoxState(); | ||
} | ||
|
||
class _CustomCheckBoxState extends State<CustomCheckBox> { | ||
ValueNotifier<bool> isChecked = ValueNotifier(false); | ||
ValueNotifier<bool> visibleSwitch = ValueNotifier(false); | ||
@override | ||
void initState() { | ||
isChecked.value = widget.isChecked ; | ||
visibleSwitch.value = widget.visibleSwitch; | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return widget.isChecked != null | ||
? ValueListenableBuilder<bool>( | ||
valueListenable: isChecked, | ||
builder: (context, value, child) { | ||
return Checkbox( | ||
value: value, | ||
onChanged: (val) { | ||
isChecked.value = val; | ||
}, | ||
); | ||
}, | ||
) | ||
: widget.visibleSwitch == null | ||
? SizedBox(height: 10, width:10,) | ||
: ValueListenableBuilder( | ||
valueListenable: visibleSwitch, | ||
builder: (context, value, child) { | ||
return Switch( | ||
onChanged: (val) { | ||
visibleSwitch.value = val; | ||
}, | ||
value: value, | ||
); | ||
}, | ||
); | ||
} | ||
} |