Problem
The widget on the next page after loading YoutubePlayerIFrame will not work.
For example, suppose you I have A and B Stateful Widgets.
First A is loaded, where YoutubePlayerIFrame
is called.
You can press the button in A, but when you move to B, the screen freezes there.
I think this is the cause of youtube_player_iframe, but page transitions may be cause, so I will write the details.
Detail
I’m developing web app using youtube_player_iframe. I wrote the following YoutubePlayerIFrame in A StatefulWidget.
YoutubePlayerIFrame(
controller: YoutubePlayerController(
initialVideoId: "NVzIALG7CUc",
params: YoutubePlayerParams(
showVideoAnnotations: false,
autoPlay: false,
startAt: Duration(seconds: 0),
showControls: true,
showFullscreenButton: false,
),
),
aspectRatio: 16 / 9,
),
Video has displayed correctly.
Page transition
Loading other pages with this code;
runApp(MaterialApp(
onGenerateRoute: (settings){
Widget wid = Home();
switch(settings.name){
case ...........
}
return PageRouteBuilder(
settings: settings,
pageBuilder: (_, __, ___) => wid,
transitionsBuilder: (_, a, __, c) =>
FadeTransition(opacity: a, child: c));
)
Then call this;
Navigator.of(context).pushReplacementNamed('/' + path);
When I remove YoutubePlayerIFrame
from code, it works.
What should I do?