'Unable to position AndroidView with video

I am using flutter 3.0.0

In my application I am displaying a native video using platform view.

The video is displaying but it is always displaying on upper left corner and it covers other widgets even they are in a stack.

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Stack(
        children: [
          Center(
            child: ConstrainedBox(
                constraints:
                    const BoxConstraints.expand(height: 200, width: 200),

                // Center is a layout widget. It takes a single child and positions it
                // in the middle of the parent.
                child:
                    const AndroidView(viewType: 'remote-video'),
                ),
          ),
          Row(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: ElevatedButton(
                  onPressed: () {
                    MethodChannels.coreMethodChannel
                        .invokeMethod("load");
                  },
                  child: const Text('Invoke'),
                ),
              ),
              
            ],
          ),

        ],
      ),
    );
  }

This is how it looks when I run the code

enter image description here

As you can see it is displaying over everything.

Can you provide some advice on how to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source