-
Notifications
You must be signed in to change notification settings - Fork 36
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
Close back layer programatically [need to document it] #76
Comments
Hi @TenPetr. Backdrop.of(context).revealBackLayer(); to reveal (show) the back layer, and Backdrop.of(context).concealBackLayer(); to conceal (hide) the back layer. If you want to use this directly within the widget in which you build your MaterialApp(
home: BackdropScaffold(
...
frontLayer: Center(
child: LayoutBuilder(
builder: (context, constraints) => RaisedButton(
onPressed: () {
Backdrop.of(context).concealBackLayer();
},
child: Text("Conceal back layer"),
),
),
),
),
); |
That is amazing! I tried this solution, but I did not have my widget wrapped in the LayoutBuilder, so that is why my code did not work. Thank you so much! |
@WieFel Should we put this in README? Under headline "Accessing the internal state of Backdrop". |
@daadu yes, I thought so too! |
I am opening this issue until it is put in README. Also |
Also need to specify that the "Builder wrapper" is not mandatory, in case if This applies to other |
@daadu Yes, I think I understand. Also, what I have noticed here, when you have one or more FloatingActionButton, they are still visible, even when back layer is toggled on. Do you think there is any setting or an option, how to hide these or should I just use Thanks a lot! |
There are callbacks in BackdropScaffold that you can use - onBackLayerConcealed and onBackLayerRevealed. |
Perfect, I will include my code snippet here onBackLayerRevealed: () => setState(() => areFloatingsVisible = false),
onBackLayerConcealed: () => setState(() => areFloatingsVisible = true), |
Also you could add the BackdropScaffold(
...
frontLayer: Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
body: Center(child: Text("Front Layer")),
),
), Like this, it is by design shown only when front layer is visible ;) |
I once had the same problem. Therefore we added |
Unfortunately, this did not help me. :/ Do you have any other idea, how to solve it, please? |
try |
I believe this property is depricated and it is not included in the BackdropScaffold at all. One solution that came to my mind is just hide inactive part like this, but it really does not solve the issue. inactiveOverlayColor: white,
inactiveOverlayOpacity: 1, |
I think the problem is more generic, not specific to |
Yes, before I used this package, I was using alerts with forms inside, and whenever keyboard show up, whole scaffold just moved up. |
Okay, I found a problem. Since I am using cards and bottom navigation bar, this issue was solved by setting |
One last question please - Is it possible to pass data from back layer back to front layer? On my back layer i have a filter and search and whenever user find desired result and tap on it, I want to pass selected data somehow back to front layer widget. (My back layer is a separate widget and since I am not using Navigator, I cant pass data between these two widgets..) Do you have any idea, how to implement this, please? |
@TenPetr this is common use case in flutter and can be solved with callbacks. Check this. Also, check the "Contextual Controls" use case in https://fluttercommunity.github.io/backdrop/demo/#/ which passes data between front- and back-layer. |
There are various ways to do it in flutter, this is known as state management. Some simpler ways are - ScopedModel, provider Some sophisticated ways are - BLoC, Redux, etc Check the following videos for it: |
For simpler cases, as @WieFel mentioned you can you callbacks. |
Thanks a lot both of you. I figured out that I can simply pass method reference to second widget and that I can call this method that is defined in the parent widget this way, so now, I can simply pass data as an argument to this function. Thanks a lot for your help, guys! |
It would be great, if you could close or toggle between front and back layers programatically without using BackdropToggleButton. I did not find a way, how to do it.
For example - I am using some filters in this widget and when user select filter, I would like to close back layer automatically, without user need to click on toggle button in the appbar's actions.
If you have any idea, how to implement this with existing code, please let me know.
Thanks for your time and suggestions.
The text was updated successfully, but these errors were encountered: