How to fix error "The instance member '_remoteConfigService' can't be accessed in an initializer."

Viewed 67

This is my first time using remote config. And I can't access it for my videoId. How do I go about it? Thanks

static String myVideoId = _remoteConfigService.getEpl01Match;
  

  YoutubePlayerController _controller = YoutubePlayerController(
    initialVideoId: myVideoId,
    flags: YoutubePlayerFlags(
      autoPlay: true,
      mute: false,
    ),
  );
1 Answers

You should use initState method to initialize that variable. This method will run only once, when the widget is built the first time. And remember that it can be usued only inside a StatefulWidget. The initialization should look like this:

static String myVideoId;

@override
void initState(){
super.initState();
myVideoId = _remoteConfigService.getEpl01Match;
}
Related