I am completely stumped on what I should do. I used the sample code from youtube_player_iframe to play a single youtube video. The only thing I changed was the videoID. Here is my code:
import 'package:flutter/material.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
class Project extends StatelessWidget{
final String title;
final String details;
final String url;
const Project(this.title,this.details,this.url,{super.key});
@override
Widget build(BuildContext context){
YoutubePlayerController _controller = YoutubePlayerController.fromVideoId(
videoId: 'TYX3wGsKpwI',
autoPlay: false,
params: YoutubePlayerParams(showFullscreenButton: true),
);
return Container(
height:400,
child: YoutubePlayer(
controller: _controller,
aspectRatio: 16 / 9,
),
);
}
}
This is the error I get when I hot-reload the page:
The following assertion was thrown building Project(dirty):
Assertion failed:
file:///C:/Users/Emma%20Ude/AppData/Local/Pub/Cache/hosted/pub.dev/webview_flutter_platform_interface-2.10.0/lib/src/platform_navigation_delegate.dart:47:7
WebViewPlatform.instance != null
"A platform implementation for `webview_flutter` has not been set. Please ensure that an
implementation of `WebViewPlatform` has been set to `WebViewPlatform.instance` before use. For unit
testing, `WebViewPlatform.instance` can be set with your own test implementation."
The relevant error-causing widget was:
Project
Project:file:///C:/Users/Emma%20Ude/Desktop/My%20Website/flutter_website/lib/widgets/portfolio_content/projects_list.dart:15:9
I am creating a flutter website, not an app so I only have to worry about it working as a website. I tried adding webview_flutter to my dependencies in pubspec.yaml to see if that would help but nothing happened.
youtube_player_iframe: ^5.1.2
webview_flutter: ^4.7.0
I figured out what the problems was. Someone commented about rebuilding the project, so I just restarted my computer all together too while I was at it. And it works now!