place this below code on parent ```StatefulWidget``` class that is MaterialApp is residing
```
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
setState(() {
if (AppLifecycleState.detached == state) {
player.stop();
}
});
}
```
or
place the MaterialApp inside a ```StatefulWidget``` and place the below code on it
```
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
setState(() {
if (AppLifecycleState.detached == state) {
player.stop();
}
});
}
```
place this below code on parent ```StatefulWidget``` class that is MaterialApp is residing
```
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
setState(() {
if (AppLifecycleState.detached == state) {
player.stop();
}
});
}
```
or
place the MaterialApp inside a ```StatefulWidget``` and place the below code on it
```
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
setState(() {
if (AppLifecycleState.detached == state) {
player.stop();
}
});
}
```