Я использую плагин youtube_player_flutter версии 9.0.1 для воспроизведения видео YouTube в своем приложении, но он выдает следующую ошибку:
The following assertion was thrown building RawYoutubePlayer(dirty, dependencies: [InheritedYoutubePlayer], state: _RawYoutubePlayerState#d7415):
A platform implementation for `flutter_inappwebview` has not been set. Please ensure that an implementation of `InAppWebViewPlatform` has been set to `InAppWebViewPlatform.instance` before use. For unit testing, `InAppWebViewPlatform.instance` can be set with your own test implementation.
'package:flutter_inappwebview_platform_interface/src/in_app_webview/platform_inappwebview_widget.dart':
Failed assertion: line 202 pos 7: 'InAppWebViewPlatform.instance != null'
Это код, в котором я использую этот плагин —
import 'package:flutter/material.dart';
import 'package:fitness_project/models/workout.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class WorkoutDetail extends StatefulWidget{
Workout? workout;
WorkoutDetail({super.key,this.workout});
@override
WorkoutDetailState createState() => WorkoutDetailState(workout: workout);
}
class WorkoutDetailState extends State{
Workout? workout;
WorkoutDetailState({this.workout});
YoutubePlayerController controller = YoutubePlayerController(
initialVideoId: 'CbggneVFrx8',
flags: YoutubePlayerFlags(autoPlay:false,
),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(automaticallyImplyLeading: false,
backgroundColor: Colors.indigoAccent,
title: Text(("Workout Details"),
style:const TextStyle(color: Colors.white)),
),
backgroundColor: Colors.black,
body: Container(
child: Center(
child:Container(
child:Column(mainAxisAlignment: MainAxisAlignment.center ,
children: [
YoutubePlayer(
controller: controller,
),
Container(decoration: BoxDecoration(border: Border.all(color: Colors.white),
color: Colors.white24,
borderRadius: BorderRadius.all(Radius.circular(15)) ),
height: 150,
padding: EdgeInsets.only(top:10,bottom: 20),
margin: EdgeInsets.only(left: 20,right:20,top:15,bottom:15),
child: Column(children: [
Text("Steps to do this workout ",style: TextStyle(color: Colors.white, fontSize: 24)),
Divider(color: Colors.white, indent: 10,endIndent:10 ),
Expanded(child: Container(
child: Text("Put your hands on ground and jump ",
style: TextStyle(color: Colors.white, fontSize: 19)), ))
],)
)],
))))
);
}
}
Я установил для minSdkVersion значение 21 android.useAndroidX=true и android.enableJetifier=true, а версия плагина Android gradle — 7.3.0. Я новичок в Flutter, и буду очень признателен за любую помощь.
Это мой pubspec.yaml-
name: fitness_project
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/arc ... nKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=3.2.5
Подробнее здесь: https://stackoverflow.com/questions/784 ... e-player-f
Ошибка flutter_inappwebview не установлена при использовании плагина youtube_player_flutter версии 9.0.1. ⇐ Android
Форум для тех, кто программирует под Android
1715794856
Anonymous
Я использую плагин youtube_player_flutter версии 9.0.1 для воспроизведения видео YouTube в своем приложении, но он выдает следующую ошибку:
The following assertion was thrown building RawYoutubePlayer(dirty, dependencies: [InheritedYoutubePlayer], state: _RawYoutubePlayerState#d7415):
A platform implementation for `flutter_inappwebview` has not been set. Please ensure that an implementation of `InAppWebViewPlatform` has been set to `InAppWebViewPlatform.instance` before use. For unit testing, `InAppWebViewPlatform.instance` can be set with your own test implementation.
'package:flutter_inappwebview_platform_interface/src/in_app_webview/platform_inappwebview_widget.dart':
Failed assertion: line 202 pos 7: 'InAppWebViewPlatform.instance != null'
Это код, в котором я использую этот плагин —
import 'package:flutter/material.dart';
import 'package:fitness_project/models/workout.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class WorkoutDetail extends StatefulWidget{
Workout? workout;
WorkoutDetail({super.key,this.workout});
@override
WorkoutDetailState createState() => WorkoutDetailState(workout: workout);
}
class WorkoutDetailState extends State{
Workout? workout;
WorkoutDetailState({this.workout});
YoutubePlayerController controller = YoutubePlayerController(
initialVideoId: 'CbggneVFrx8',
flags: YoutubePlayerFlags(autoPlay:false,
),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(automaticallyImplyLeading: false,
backgroundColor: Colors.indigoAccent,
title: Text(("Workout Details"),
style:const TextStyle(color: Colors.white)),
),
backgroundColor: Colors.black,
body: Container(
child: Center(
child:Container(
child:Column(mainAxisAlignment: MainAxisAlignment.center ,
children: [
YoutubePlayer(
controller: controller,
),
Container(decoration: BoxDecoration(border: Border.all(color: Colors.white),
color: Colors.white24,
borderRadius: BorderRadius.all(Radius.circular(15)) ),
height: 150,
padding: EdgeInsets.only(top:10,bottom: 20),
margin: EdgeInsets.only(left: 20,right:20,top:15,bottom:15),
child: Column(children: [
Text("Steps to do this workout ",style: TextStyle(color: Colors.white, fontSize: 24)),
Divider(color: Colors.white, indent: 10,endIndent:10 ),
Expanded(child: Container(
child: Text("Put your hands on ground and jump ",
style: TextStyle(color: Colors.white, fontSize: 19)), ))
],)
)],
))))
);
}
}
Я установил для minSdkVersion значение 21 android.useAndroidX=true и android.enableJetifier=true, а версия плагина Android gradle — 7.3.0. Я новичок в Flutter, и буду очень признателен за любую помощь.
Это мой pubspec.yaml-
name: fitness_project
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=3.2.5
Подробнее здесь: [url]https://stackoverflow.com/questions/78468595/getting-error-flutter-inappwebview-has-not-been-set-while-using-youtube-player-f[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия