Home > database >  The operator '..' is not working in flutter - dart code
The operator '..' is not working in flutter - dart code

Time:11-09

I am looking at the following video where they use the .. operator inside initState()

broken operator

video image

what am i doing wrong?

CodePudding user response:

I believe you have extra supply of ;

 void initState() {
    super.initState();
    // select where the video is coming from  asset/file/network
    _videoPlayerController = VideoPlayerController.asset(asset)
    ..setListener( ()=> setState(() {})); // error: expected an identifier
    ..setLooping(true);  // error: expected an identifier
    ..initialize();  // error: expected an identifier
  }

CodePudding user response:

You are using ; after each line, in order to use .. you don't need to use ; at the end of line, so try this:

void initState() {
    super.initState();
    // select where the video is coming from  asset/file/network
    _videoPlayerController = VideoPlayerController.asset(asset)
    ..setListener( ()=> setState(() {})) 
    ..setLooping(true)
    ..initialize();  
  }

CodePudding user response:

You can find your problem in this links:

https://stackoverflow.com/a/49447872/19122402

https://dart.dev/guides/language/language-tour#cascade-notation-

  • Related