'Flutter show/hide widget
I'm trying to show a widget onFinished countdown timer but I can't seem to make it work. I've added var reqPIN = false;
And here is my code:
children [
Countdown(
seconds: 3,
build: (_, double time) =>
RichText(
text: TextSpan(
text: 'Reset PIN in ',
style: TextStyle(
color: Theme.of(context).inputDecorationTheme.labelStyle?.color
),
children: <TextSpan>[
TextSpan(
text: time.toString(),
style: TextStyle(
color: Color(0xFF2481CF),
fontWeight: FontWeight.bold
)),
TextSpan(text: ' sec',
style: TextStyle(
color: Theme.of(context).inputDecorationTheme.labelStyle?.color
))
]
),
),
onFinished: () {
setState(() {
reqPIN = true;
});
},
),
SizedBox(
child: Visibility(
visible: reqPIN,
child: Text('Resend PIN',
style: TextStyle(
color: Colors.black
),),
),
)
]
Is there any solution?
Solution 1:[1]
Try this one.
if (reqPIN)
SizedBox(
child: Text('Resend PIN', style: TextStyle(color: Colors.black)),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kamal Nathani |
