Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[readme] added "Accessing underlying backdrop functionalities" section #77

Merged
merged 6 commits into from
Feb 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,23 @@ Widget build(BuildContext context) {
<img src="https://github.com/fluttercommunity/backdrop/raw/master/.github/backdrop_navigation.gif" height="500" alt="BackdropNavigationScaffold example">
</div>

For more information, check out sample code in the [example directory](https://github.com/fluttercommunity/backdrop/tree/master/example)
### Accessing underlying backdrop functionalities
To access backdrop related functionalities, use `Backdrop.of(context)` to get underlying `BackdropScaffoldState`.

`BackdropScaffoldState` exposes various properties and methods like:
- properties
- `controller -> AnimationController`
- `scaffoldKey -> GlobalKey<ScaffoldState> `
- `isBackLayerConcealed -> bool`
- `isBackLayerRevealed -> bool`
- methods
- `fling()`
- `concealBackLayer()`
- `revealBackLayer()`

Note: `Backdrop` is an `InheritedWidget` and therefore like `Scaffold.of`, `Theme.of` and `MediaQuery.of`, the `BuildContext context` passed to `Backdrop.of(context)` should be of a `Widget` that is under the `BackdropScaffold` in the "widget tree". In other words, `Backdrop.of` called inside a widget where the `BackdropScaffold` is initalized will not work explicitly, since the `context` passed is of the widget that will build `BackdropScaffold` therefore above `BackdropScaffold`. This can be solved by either making a seperate `Widget` where `Backdrop.of` needs to be used and make it the "child" of `BackdropScaffold` or wrap the `Backdrop.of` usage around `Builder` widget so that the "correct" `context` (from `Builder`) is passed to `Backdrop.of`. This [answere on SO](https://stackoverflow.com/a/52123080/2554745) and [FWotW video on Builder](https://www.youtube.com/watch?v=xXNOkIuSYuA) gives a very good idea of how and why `Builder` works in later case.

For more information, check out sample code in the [example directory](https://github.com/fluttercommunity/backdrop/tree/master/example), [demo app](https://fluttercommunity.github.io/backdrop/demo/#/) with use-cases and code for it and [API references](https://pub.dev/documentation/backdrop/latest/backdrop/backdrop-library.html) generated by pub.dev.

## Contribute
Check proposal documents for [v1.0](https://github.com/fluttercommunity/backdrop/issues/5) and [web&desktop](https://github.com/fluttercommunity/backdrop/issues/34) milestones before you begin with any contibution.
Expand Down