Update README.md

This commit is contained in:
David Peters 2020-09-26 16:19:58 +02:00 committed by GitHub
parent 593302e7d4
commit a75b423314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 11 deletions

View File

@ -12,14 +12,19 @@ See the demo below for an example.
## Usage
```dart
Miniplayer(
minHeight: 70,
maxHeight: 370,
builder: (height, percentage) {
return Center(
child: Text('$height, $percentage'),
);
},
Stack(
children: <Widget>[
YourApp(),
Miniplayer(
minHeight: 70,
maxHeight: 370,
builder: (height, percentage) {
return Center(
child: Text('$height, $percentage'),
);
},
),
],
),
```
@ -68,9 +73,12 @@ Miniplayer(
</tr>
</table>
### Usage without BottomNavigationBar
This method is only recommended for simple apps. If you want to use dialogs or persistent widgets such as a BottomNavigationBar, use the second (slightly more advanced) method as described in the [example](https://pub.dev/packages/miniplayer/example) which uses Navigator as a base.
## Persistence
Implementing the miniplayer as described under [usage](https://pub.dev/packages/miniplayer#usage) - for instance by wrapping it in a stack alongside the `Scaffold` body - would work out of the box but has some disadvantages. If you push a new screen via `Navigator.push` the miniplayer would disappear. What we want is a persistent miniplayer which stays on every screen.
You have the option of two methods when it comes to archiving the miniplayer's persistent state, which depends on the use case. The first method is only recommended for simple apps and use cases. If you want to use dialogs or persistent widgets such as a BottomNavigationBar, use the second (slightly more advanced) method
## First method (Simple)
```dart
import 'package:flutter/material.dart';
import 'package:miniplayer/miniplayer.dart';
@ -108,6 +116,6 @@ class MyApp extends StatelessWidget {
}
```
### Usage with BottomNavigationBar
## Second method (Advanced)
[See example](https://pub.dev/packages/miniplayer/example)