How to call data from Stateful class to State

Viewed 40

I have this Stateful class and I wanna took "Data" from Stateful class to State class

Here is my code:

class PlayMode extends StatefulWidget {
  final Data data;
  PlayMode({this.data}); // Pass this to State class

  @override
  State<StatefulWidget> createState() {
    return new PlayModeState();
  }
}

How it can be done?

1 Answers

In your PlayModeState class, simply use

widget.data
Related