I think you can use youtube_player_flutter package to play YouTube videos. - Follow the instruction on Installing tab. Then try to run following:
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: 'iLnmTe5Q2Qw',
flags: YoutubePlayerFlags(
autoPlay: true,
mute: true,
),
);
return Scaffold(
appBar: AppBar(
title: Text("Youtube test"),
),
body: Center(
child: YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: true,
progressIndicatorColor: Colors.amber,
onReady: () {
print("player ready..");
},
),
),
);
}
}
If you like to see more option, you can also take a look at a more detailed example: here