'get access to a variable in class B and use it in class A
I want to get access to variable ' a ' of class ' B' and use it in the condition of A class. what would i give to condition of class A ?
class A extends StatefulWidget
{
const A({ Key? key }) : super(key: key);
@override
_AState createState() => _AState();
}
class _AState extends State<A>
{
String picture = "a";
String title = "b";
@override
Widget build(BuildContext context)
{
if ( ??????? == 1) {
setState(() {
picture = "t";
title = "y";
return Scaffold()....
}
class B extends StatelessWidget
{`enter code here`
int? a;
@override
Widget build(BuildContext context)
{
return GestureDetector(
child: Container(...)),
onTap: ()
{
a = 1;
},
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
