mirror of
https://github.com/iampawan/Flutter-Music-Player.git
synced 2025-08-06 14:52:05 +08:00
58 lines
1.9 KiB
Dart
58 lines
1.9 KiB
Dart
import 'package:flute_example/pages/now_playing.dart';
|
|
import 'package:flute_example/widgets/mp_inherited.dart';
|
|
import 'package:flute_example/widgets/mp_lisview.dart';
|
|
import 'package:flute_music_player/flute_music_player.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class RootPage extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final rootIW = MPInheritedWidget.of(context);
|
|
//Goto Now Playing Page
|
|
void goToNowPlaying(Song s, {bool nowPlayTap: false}) {
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (context) => new NowPlaying(
|
|
rootIW.songData,
|
|
s,
|
|
nowPlayTap: nowPlayTap,
|
|
)));
|
|
}
|
|
|
|
//Shuffle Songs and goto now playing page
|
|
void shuffleSongs() {
|
|
goToNowPlaying(rootIW.songData.randomSong);
|
|
}
|
|
|
|
return new Scaffold(
|
|
appBar: new AppBar(
|
|
title: new Text("Flutter Music Player"),
|
|
actions: <Widget>[
|
|
new Container(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: new Center(
|
|
child: new InkWell(
|
|
child: new Text("Now Playing"),
|
|
onTap: () => goToNowPlaying(
|
|
rootIW.songData.songs[
|
|
(rootIW.songData.currentIndex == null ||
|
|
rootIW.songData.currentIndex < 0)
|
|
? 0
|
|
: rootIW.songData.currentIndex],
|
|
nowPlayTap: true,
|
|
)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
// drawer: new MPDrawer(),
|
|
body: rootIW.isLoading
|
|
? new Center(child: new CircularProgressIndicator())
|
|
: new Scrollbar(child: new MPListView()),
|
|
floatingActionButton: new FloatingActionButton(
|
|
child: new Icon(Icons.shuffle), onPressed: () => shuffleSongs()),
|
|
);
|
|
}
|
|
}
|