Reputation: 479
I would like to print the values of boolean inside the widget Visibility
how can I do it ?
Stack(
children: [
Scaffold(
body: Container(
//change the margin
margin: EdgeInsets.fromLTRB(0, 0, 0, 300),
child:
Visibility(
visible: mapVisible,
// print the value of the boolean mapVisible
maintainSemantics: true,
maintainInteractivity: true,
maintainAnimation: true,
maintainState: true,
maintainSize: true,
replacement: Container(), )
Upvotes: 0
Views: 552
Reputation: 1465
Your question is rather vague. It could be one of 2 things.
To print the variable value every time the widget builds you can just move the logic into a method like such.
bool mapVisible = true;
Stack(
children: [
Scaffold(
body: Container(
//change the margin
margin: EdgeInsets.fromLTRB(0, 0, 0, 300),
child:
Visibility(
visible: _shouldShow,
// print the value of the boolean mapVisible
maintainSemantics: true,
maintainInteractivity: true,
maintainAnimation: true,
maintainState: true,
maintainSize: true,
replacement: Container(), )
bool _shouldShow()
{
print(mapVisible);
return mapVisible;
}
or to display the variable as text to the user you can do the following.
Stack(
children: [
Scaffold(
body: Container(
//change the margin
margin: EdgeInsets.fromLTRB(0, 0, 0, 300),
child:
Visibility(
visible: mapVisible,
// print the value of the boolean mapVisible
maintainSemantics: true,
maintainInteractivity: true,
maintainAnimation: true,
maintainState: true,
maintainSize: true,
replacement: Container(),
child:Text(mapVisible.toString()),//-->show it a widget
)
Upvotes: 2