Last active
April 17, 2019 15:46
-
-
Save felixblaschke/459d5bf4d54bd5fe0cf2fa0fac1ad328 to your computer and use it in GitHub Desktop.
Switchlike Checkbox Part 2
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
class SwitchlikeCheckbox extends StatelessWidget { | |
// ... | |
// all code from part 1 | |
Widget _buildCheckbox(context, animation) { | |
return Container( | |
decoration: _outerBoxDecoration(animation["color"]), | |
width: 50, | |
height: 30, | |
padding: const EdgeInsets.all(3.0), | |
child: Stack( | |
children: [ | |
Positioned( | |
child: Padding( | |
padding: EdgeInsets.only(left: animation["paddingLeft"]), | |
child: Transform.rotate( | |
angle: animation["rotation"], | |
child: Container( | |
decoration: _innerBoxDecoration(animation["color"]), | |
width: 20, | |
child: | |
Center(child: Text(animation["text"], style: labelStyle)), | |
), | |
), | |
)) | |
], | |
), | |
); | |
} | |
BoxDecoration _innerBoxDecoration(color) => BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(25)), color: color); | |
BoxDecoration _outerBoxDecoration(color) => BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(30)), | |
border: Border.all( | |
width: 2, | |
color: color, | |
), | |
); | |
static final labelStyle = TextStyle( | |
height: 1.2, | |
fontWeight: FontWeight.bold, | |
fontSize: 9, | |
color: Colors.white); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment