import 'package:flutter/material.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart'; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State { YoutubePlayerController _youtubePlayerController = YoutubePlayerController( initialVideoId: "Pvd1Y0OR2Nk", flags: const YoutubePlayerFlags(autoPlay: true, mute: true)); @override void initState() { super.initState(); } PageController pageController = PageController(initialPage: 0); int currentIndex = 0; List list = [ Text("Home 1"), Text("Home 2"), Text("Home 3"), Text("Home 4"), Text("Home 5"), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Youtube"), ), body: Column( children: [ currentIndex == 0 ? Text("Home 1") : Container(), currentIndex == 1 ? Text("Home 2") : Container(), currentIndex == 2 ? Text("Home 3") : Container(), currentIndex == 3 ? Text("Home 4") : Container(), currentIndex == 4 ? Text("Home 5") : Container(), ], ), // body: list[currentIndex], // body: PageView( // controller: pageController, // children: [ // Text("Home 1"), // Text("Home 2"), // Text("Home 3"), // Text("Home 4"), // Text("Home 5"), // ], // onPageChanged: (index) { // currentIndex = index; // setState(() {}); // }, // ), bottomNavigationBar: BottomNavigationBar( currentIndex: currentIndex, backgroundColor: Colors.amber, onTap: (index) { // pageController.animateToPage(index, // duration: Duration(milliseconds: 100), // curve: Curves.easeInBack); currentIndex = index; setState(() {}); }, items: [ BottomNavigationBarItem( icon: Icon(Icons.holiday_village), backgroundColor: Colors.red, label: "Home"), BottomNavigationBarItem( icon: Icon(Icons.holiday_village), backgroundColor: Colors.red, label: "Home"), BottomNavigationBarItem( icon: Icon(Icons.holiday_village), backgroundColor: Colors.red, label: "Home"), BottomNavigationBarItem( icon: Icon(Icons.holiday_village), backgroundColor: Colors.red, label: "Home"), BottomNavigationBarItem( icon: Icon(Icons.holiday_village), backgroundColor: Colors.red, label: "Home"), ]), ); } }