class Astate extends State<A>
{
List b=new List<B>();
@override
Widget build(BuildContext context){
b.add(B());
//how do I access theMethod() for the state object for b[0]?
}
}
class B extends StatefulWidget
{
@override
Bstate createState() => Bstate();
}
class Bstate extends State<B>
{
theMethod()
{
//some content
}
@override
Widget build(BuildContext context) {
}
}
有没有办法使用 b[0] 从它的相应状态对象访问 theMethod() ?如果没有,是否有另一种方法可以达到同样的效果?