我想从另一个类访问此方法updateCounter()
。我该怎么称呼它?或者如何实例化_HomePageState
?
这是我的代码:
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
static int i=0;
void updateCounter(int counter) {
print(counter);
setState(() {
i=counter;
});
}
@override
Widget build(BuildContext context) {
return Container(
);
}
}