Skip to content

Commit ce3116b

Browse files
authored
[readme] added "Accessing underlying backdrop functionalities" section (#77)
1 parent 2783653 commit ce3116b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,23 @@ Widget build(BuildContext context) {
101101
<img src="https://github.com/fluttercommunity/backdrop/raw/master/.github/backdrop_navigation.gif" height="500" alt="BackdropNavigationScaffold example">
102102
</div>
103103

104-
For more information, check out sample code in the [example directory](https://github.com/fluttercommunity/backdrop/tree/master/example)
104+
### Accessing underlying backdrop functionalities
105+
To access backdrop related functionalities, use `Backdrop.of(context)` to get underlying `BackdropScaffoldState`.
106+
107+
`BackdropScaffoldState` exposes various properties and methods like:
108+
- properties
109+
- `controller -> AnimationController`
110+
- `scaffoldKey -> GlobalKey<ScaffoldState> `
111+
- `isBackLayerConcealed -> bool`
112+
- `isBackLayerRevealed -> bool`
113+
- methods
114+
- `fling()`
115+
- `concealBackLayer()`
116+
- `revealBackLayer()`
117+
118+
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.
119+
120+
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.
105121

106122
## Contribute
107123
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.

0 commit comments

Comments
 (0)