Steps to Reproduce
I am trying to implement a video player in may application.
I used "native_video_view: ^1.0.5" plugin for that.It worked as expected on Flutter 2.10.5.
But not working properly on the current stable version of flutter( Flutter 3.0.4 ).
In stable version, the video player widget displaying over all the other views in the device.And also sticks to the top of the display.
Then i tried it with latest flutter from github(Flutter 3.1.0-0.0.pre.2428).
In that case it showing a crash.But if I run it with 'flutter run ' command , then it will run, but showing same issue as in the stable version.
Below is my implementation of the native_video_view.
code sample
import 'package:flutter/material.dart';
import 'package:native_video_view/native_video_view.dart';
void main() => runApp(const MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: _buildVideoPlayerWidget(),
);
}
Widget _buildVideoPlayerWidget() {
return Container(
alignment: Alignment.center,
child: NativeVideoView(
keepAspectRatio: true,
showMediaController: true,
enableVolumeControl: true,
onCreated: (controller) {
controller.setVideoSource(
'assets/example.mp4',
sourceType: VideoSourceType.asset,
requestAudioFocus: true,
);
},
onPrepared: (controller, info) {
debugPrint('NativeVideoView: Video prepared');
controller.play();
},
onError: (controller, what, extra, message) {
debugPrint(
'NativeVideoView: Player Error ($what | $extra | $message)');
},
onCompletion: (controller) {
debugPrint('NativeVideoView: Video completed');
},
),
);
}
}
| Expected results |
Actual results |
 |
 |
Log
Running "flutter pub get" in videoplayernativeplatform...
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Debug service listening on ws://127.0.0.1:49988/LsQCbapa508=/ws
Syncing files to device sdk gphone64 arm64...
I/PlatformViewsController(10892): Hosting view in a virtual display for platform view: 0
E/flutter (10892): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Unexpected platform view context. When constructing a platform view in the factory, use the context from PlatformViewFactory#create, view id: 0
E/flutter (10892): at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:187)
E/flutter (10892): at android.app.Dialog.dispatchOnCreate(Dialog.java:432)
E/flutter (10892): at android.app.Dialog.show(Dialog.java:321)
E/flutter (10892): at android.app.Presentation.show(Presentation.java:279)
E/flutter (10892): at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:119)
E/flutter (10892): at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:64)
E/flutter (10892): at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:267)
E/flutter (10892): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:122)
E/flutter (10892): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/flutter (10892): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:261)
E/flutter (10892): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (10892): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:321)
E/flutter (10892): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (10892): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (10892): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (10892): at android.os.Looper.loopOnce(Looper.java:201)
E/flutter (10892): at android.os.Looper.loop(Looper.java:288)
E/flutter (10892): at android.app.ActivityThread.main(ActivityThread.java:7842)
E/flutter (10892): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (10892): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/flutter (10892): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/flutter (10892): , null, null)
E/flutter (10892): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter (10892): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
E/flutter (10892): <asynchronous suspension>
E/flutter (10892): #2 TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1146:18)
E/flutter (10892): <asynchronous suspension>
E/flutter (10892): #3 AndroidViewController.create (package:flutter/src/services/platform_views.dart:792:5)
E/flutter (10892): <asynchronous suspension>
E/flutter (10892): #4 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:819:7)
E/flutter (10892): <asynchronous suspension>
E/flutter (10892): #5 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:182:29)
E/flutter (10892): <asynchronous suspension>
E/flutter (10892):
W/System (10892): A resource failed to call release.
D/EGL_emulation(10892): app_time_stats: avg=954.98ms min=3.11ms max=2768.19ms count=3
Logs
flutter analyze
Analyzing videoplayernativeplatform...
No issues found! (ran in 1.7s)
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.5.1 21G83 darwin-arm, locale en-IN)
• Flutter version 3.0.4 at /Users/linslouis/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 85684f9300 (8 weeks ago), 2022-06-30 13:22:47 -0700
• Engine revision 6ba2af10bb
• Dart version 2.17.5
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/linslouis/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/linslouis/Library/Android/sdk
• Java binary at: /Users/linslouis/Library/Java/JavaVirtualMachines/azul-15.0.8/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Zulu15.42+15-CA (build 15.0.8+4-MTS)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 32) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.5.1 21G83 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.101
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Steps to Reproduce
I am trying to implement a video player in may application.
I used "native_video_view: ^1.0.5" plugin for that.It worked as expected on Flutter 2.10.5.
But not working properly on the current stable version of flutter( Flutter 3.0.4 ).
In stable version, the video player widget displaying over all the other views in the device.And also sticks to the top of the display.
Then i tried it with latest flutter from github(Flutter 3.1.0-0.0.pre.2428).
In that case it showing a crash.But if I run it with 'flutter run ' command , then it will run, but showing same issue as in the stable version.
Below is my implementation of the native_video_view.
code sample
Log
Logs
flutter doctor -v