As I learned that state of StatefulWidget widget in flutter defined as private and both of snippet of VS Code , and android studio do this like below on _RectAnsState
class RectAns extends StatefulWidget {
final String title;
const RectAns(this.title, {Key key}) : super(key: key);
@override
_RectAnsState createState() => _RectAnsState();
}
class _RectAnsState extends State<RectAns> {
Color _color = Colors.transparent;
@override
Widget build(BuildContext context) {
return Container()}
}
although i pass GlobalKey to widget so i can use this key to get currentState object , but i need to define that currentState object type from other files , but it's type is private class then its must be public here, what wrong of my implementation
GlobalKey gk = new GlobalKey();
RectAns rectAns = new RectAns(count.toString(), key: gk);
and on other file i want to get this state to call function inside and setState
RectAnsState rt = gk.currentState
above RectAnsState is private , so is the correct way to make it public?????