@@ -69,38 +69,44 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
69
69
@override
70
70
Widget build (BuildContext context) {
71
71
return new MaterialApp (
72
- home: new Scaffold (
73
- appBar: new AppBar (
74
- title: const Text ('Audio Service Demo' ),
75
- ),
76
- body: new Center (
77
- child: StreamBuilder (
78
- stream: AudioService .playbackStateStream,
79
- builder: (context, snapshot) {
80
- PlaybackState state = snapshot.data;
81
- return Row (
82
- mainAxisAlignment: MainAxisAlignment .center,
83
- children: [
84
- if (state? .basicState == BasicPlaybackState .connecting) ...[
85
- stopButton (),
86
- Text ("Connecting..." ),
87
- ] else
88
- if (state? .basicState == BasicPlaybackState .playing) ...[
72
+ home: WillPopScope (
73
+ onWillPop: () {
74
+ disconnect ();
75
+ return Future .value (true );
76
+ },
77
+ child: new Scaffold (
78
+ appBar: new AppBar (
79
+ title: const Text ('Audio Service Demo' ),
80
+ ),
81
+ body: new Center (
82
+ child: StreamBuilder (
83
+ stream: AudioService .playbackStateStream,
84
+ builder: (context, snapshot) {
85
+ PlaybackState state = snapshot.data;
86
+ return Row (
87
+ mainAxisAlignment: MainAxisAlignment .center,
88
+ children: [
89
+ if (state? .basicState == BasicPlaybackState .connecting) ...[
90
+ stopButton (),
91
+ Text ("Connecting..." ),
92
+ ] else if (state? .basicState ==
93
+ BasicPlaybackState .playing) ...[
89
94
pauseButton (),
90
95
stopButton (),
91
96
positionIndicator (state),
92
- ] else
93
- if (state? .basicState == BasicPlaybackState .paused) ...[
94
- playButton (),
95
- stopButton (),
96
- positionIndicator (state),
97
- ] else ...[
98
- audioPlayerButton (),
99
- textToSpeechButton (),
100
- ],
101
- ],
102
- );
103
- },
97
+ ] else if (state? .basicState ==
98
+ BasicPlaybackState .paused) ...[
99
+ playButton (),
100
+ stopButton (),
101
+ positionIndicator (state),
102
+ ] else ...[
103
+ audioPlayerButton (),
104
+ textToSpeechButton (),
105
+ ],
106
+ ],
107
+ );
108
+ },
109
+ ),
104
110
),
105
111
),
106
112
),
0 commit comments