title: Error while trying to access video url from arguments from pushNamed in flutter
body: <p>I am trying to pass URL to <code>video controller</code> via <code>pushNamed</code> in flutter.</p>
  
  <p><code>error</code> i am facing is as followed </p>
  
  <pre><code>
  I/ExoPlayerImpl(29662): Release 2d82dca [ExoPlayerLib/2.9.6] [ASUS_X00T_2, ASUS_X00TD, asus, 28] [goog.exo.core]
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  E/BufferQueueProducer(29662): [SurfaceTexture-0-29662-5] cancelBuffer: BufferQueue has been abandoned
  I/chatty  (29662): uid=10085(com.example.demo_app) JNISurfaceTextu identical 5 lines
  E/BufferQueueProducer(29662): [SurfaceTexture-0-29662-5] cancelBuffer: BufferQueue has been abandoned
  D/SurfaceUtils(29662): disconnecting from surface 0x7b16f15010, reason disconnectFromSurface
  I/ExoPlayerImpl(29662): Init 3c27ac9 [ExoPlayerLib/2.9.6] [ASUS_X00T_2, ASUS_X00TD, asus, 28]
  I/OMXClient(29662): IOmx service obtained
  D/SurfaceUtils(29662): connecting to surface 0x7b17399010, reason connectToSurface
  I/MediaCodec(29662): [OMX.qcom.video.decoder.avc] setting surface generation to 30373895
  D/SurfaceUtils(29662): disconnecting from surface 0x7b17399010, reason connectToSurface(reconnect)
  D/SurfaceUtils(29662): connecting to surface 0x7b17399010, reason connectToSurface(reconnect)
  I/ExtendedACodec(29662): setupVideoDecoder()
  I/ExtendedACodec(29662): Decoder will be in frame by frame mode
  D/SurfaceUtils(29662): set up nativeWindow 0x7b17399010 for 1280x720, color 0x7fa30c06, rotation 0, usage 0x20002900
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  I/OMXClient(29662): IOmx service obtained
  I/ACodec  (29662): codec does not support config priority (err -2147483648)
  I/ACodec  (29662): codec does not support config priority (err -2147483648)
  I/ACodec  (29662): codec does not support config operating rate (err -2147483648)
  W/ExtendedACodec(29662): Failed to get extension for extradata parameter
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  D/SurfaceUtils(29662): set up nativeWindow 0x7b17399010 for 1280x720, color 0x7fa30c06, rotation 0, usage 0x20002900
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  I/chatty  (29662): uid=10085(com.example.demo_app) CodecLooper identical 1 line
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(29662): buffer descriptor with invalid usage bits 0x2000
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  I/flutter (29662): https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
  Lost connection to device.
  
  
  </code></pre>
  
  <p>code for the <code>DemoShowScreen</code> is as followed</p>
  
  <pre class="lang-dart prettyprint-override"><code>
  import 'package:flutter/material.dart';
  import '../../models/show.dart';
  import 'package:video_player/video_player.dart';
  
  class DemoShow extends StatefulWidget {
  
    static const id = "show_show_screen";
  
    @override
    _DemoShowState createState() =&gt; _DemoShowState();
  }
  
  class _DemoShowState extends State&lt;DemoShow&gt; {
    VideoPlayerController _controller;
    Future&lt;void&gt; _initializeVideoPlayerFuture;
    Show data;
  
    var media;
  
    @override
    void initState() {
      // Create and store the VideoPlayerController. The VideoPlayerController
      // offers several different constructors to play videos from assets, files,
      // or the internet.
        media = 'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4';
        _controller = VideoPlayerController.network(media);      
        // Initialize the controller and store the Future for later use.
        _initializeVideoPlayerFuture = _controller.initialize();
  
        // Use the controller to loop the video.
        _controller.setLooping(false);
  
  
      super.initState();
    }
  
    @override
    void dispose() {
      // Ensure disposing of the VideoPlayerController to free up resources.
      _controller.dispose();
  
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      data = ModalRoute.of(context).settings.arguments;
      setState(() {
        media = data.mediaUrl;
        print(media);
      });
      return Scaffold(
        appBar: AppBar(
          title: Text('${data.title}', style: Theme.of(context).textTheme.title,),
        ),
        // Use a FutureBuilder to display a loading spinner while waiting for the
        // VideoPlayerController to finish initializing.
        body: SingleChildScrollView(
          child: Container(
            child: Column(
              children: &lt;Widget&gt;[
                FutureBuilder(
                  future: _initializeVideoPlayerFuture,
                  builder: (context, snapshot) {
                    if (snapshot.connectionState == ConnectionState.done) {
                      // If the VideoPlayerController has finished initialization, use
                      // the data it provides to limit the aspect ratio of the video.
                      return AspectRatio(
                        aspectRatio: _controller.value.aspectRatio,
                        // Use the VideoPlayer widget to display the video.
                        child: VideoPlayer(_controller),
                      );
                    } else {
                      // If the VideoPlayerController is still initializing, show a
                      // loading spinner.
                      return Center(child: CircularProgressIndicator());
                    }
                  },
                ),
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            // Wrap the play or pause in a call to `setState`. This ensures the
            // correct icon is shown.
            setState(() {
              // If the video is playing, pause it.
              if (_controller.value.isPlaying) {
                _controller.pause();
              } else {
                // If the video is paused, play it.
                _controller.play();
                _controller.seekTo(Duration(seconds: 32));
              }
            });
          },
          // Display the correct icon depending on the state of the player.
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ), // This trailing comma makes auto-formatting nicer for build methods.
      );
    }
  }
  
  </code></pre>
  
  <p>What I am trying to replace the <code>butterfly.mp4</code> URL with <code>bee.mp4</code> URL which I got from the pushNamed arguments.</p>
  
  <p>On-screen I can see the <code>butterfly.mp4</code> frame in video player but it never plays or update with <code>bee.mp4</code> </p>
  
  <p>also, I tried calling the <code>ModalRoute.of(context).settings.arguments;</code> in <code>initState</code> but end up with <code>null</code> so that code is been removed.</p>
  
  ### edit after updating code
  
  <p>the video frame changed to current video but i am still facing the issue for playing video.</p>
  
  <p>New Code with <code>Stateless Widget</code>:</p>
  
  <pre class="lang-dart prettyprint-override"><code>
  import 'package:flutter/material.dart';
  import '../../models/demo.dart';
  import 'package:video_player/video_player.dart';
  
  class DemoShowScreen extends StatelessWidget {
    static const id = "demo_show_screen";
    VideoPlayerController _controller;
    Future&lt;void&gt; _initializeVideoPlayerFuture;
  
    @override
    Widget build(BuildContext context) {
      Show data = ModalRoute.of(context).settings.arguments;
      _controller = VideoPlayerController.network(data.mediaUrl);
      _controller.setLooping(false);  
      return Scaffold(
        body: Column(
          children: &lt;Widget&gt;[
            Container(
              child: FutureBuilder(
                future: _controller.initialize(),
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.done) {
                    // If the VideoPlayerController has finished initialization, use
                    // the data it provides to limit the aspect ratio of the video.
                    return AspectRatio(
                      aspectRatio: _controller.value.aspectRatio,
                      // Use the VideoPlayer widget to display the video.
                      child: VideoPlayer(_controller),
                    );
                  } else {
                    // If the VideoPlayerController is still initializing, show a
                    // loading spinner.
                    return Center(child: CircularProgressIndicator());
                  }
                },
              ),
            ),
          ],
        ),
        floatingActionButton: FloatingActionButton(
            onPressed: () {
              // Wrap the play or pause in a call to `setState`. This ensures the
              // correct icon is shown.
  
                // If the video is playing, pause it.
                if (_controller.value.isPlaying) {
                  _controller.pause();
                } else {
                  // If the video is paused, play it.
                  _controller.play();
                  _controller.seekTo(Duration(seconds: 32));
                }
            },
            // Display the correct icon depending on the state of the player.
            child: Icon(
              _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
            ),
        ),
      );
    }
  }
  
  
  </code></pre>
  
  <p>error code :</p>
  
  <pre><code>I/ExoPlayerImpl(22057): Release 877cbe7 [ExoPlayerLib/2.9.6] [ASUS_X00T_2, ASUS_X00TD, asus, 28] [goog.exo.core]
  E/BufferQueueProducer(22057): [SurfaceTexture-0-22057-1] cancelBuffer: BufferQueue has been abandoned
  I/chatty  (22057): uid=10085(com.example.demo_app) JNISurfaceTextu identical 5 lines
  E/BufferQueueProducer(22057): [SurfaceTexture-0-22057-1] cancelBuffer: BufferQueue has been abandoned
  D/SurfaceUtils(22057): disconnecting from surface 0x7b17aa2010, reason disconnectFromSurface
  I/ExoPlayerImpl(22057): Init cf82360 [ExoPlayerLib/2.9.6] [ASUS_X00T_2, ASUS_X00TD, asus, 28]
  I/OMXClient(22057): IOmx service obtained
  D/SurfaceUtils(22057): connecting to surface 0x7b337e0010, reason connectToSurface
  I/MediaCodec(22057): [OMX.qcom.video.decoder.avc] setting surface generation to 22586371
  D/SurfaceUtils(22057): disconnecting from surface 0x7b337e0010, reason connectToSurface(reconnect)
  D/SurfaceUtils(22057): connecting to surface 0x7b337e0010, reason connectToSurface(reconnect)
  I/ExtendedACodec(22057): setupVideoDecoder()
  I/ExtendedACodec(22057): Decoder will be in frame by frame mode
  D/SurfaceUtils(22057): set up nativeWindow 0x7b337e0010 for 1280x720, color 0x7fa30c06, rotation 0, usage 0x20002900
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  I/OMXClient(22057): IOmx service obtained
  I/ACodec  (22057): codec does not support config priority (err -2147483648)
  I/ACodec  (22057): codec does not support config priority (err -2147483648)
  I/ACodec  (22057): codec does not support config operating rate (err -2147483648)
  W/ExtendedACodec(22057): Failed to get extension for extradata parameter
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  D/SurfaceUtils(22057): set up nativeWindow 0x7b337e0010 for 1280x720, color 0x7fa30c06, rotation 0, usage 0x20002900
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000
  W/MapperHal(22057): buffer descriptor with invalid usage bits 0x2000 
  </code></pre>