Instantly share code, notes, and snippets.

Embed
What would you like to do?
class _GenderCardState extends State<GenderCard> {
Gender selectedGender;
@override
void initState() {
selectedGender = widget.initialGender ?? Gender.other; //<--- initialize selected gender
super.initState();
}
Widget _drawMainStack() {
return Container(
width: double.infinity, //<--- Expand stack width
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
_drawCircleIndicator(),
GenderIconTranslated(gender: Gender.female),
GenderIconTranslated(gender: Gender.other),
GenderIconTranslated(gender: Gender.male),
_drawGestureDetector(), //<--- Add gesutre detector
],
),
);
}
Widget _drawCircleIndicator() {
return Stack(
alignment: Alignment.center,
children: <Widget>[
GenderCircle(),
GenderArrow(angle: _genderAngles[selectedGender]),//<--- make arrow display current gender
],
);
}
_drawGestureDetector() {
return Positioned.fill(
child: TapHandler(
onGenderTapped: (gender) => setState(() => selectedGender = gender),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment