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
Fix Scaffold.of(context) calls and update Scaffold constructors #4
Conversation
I also added the option for action to be taken on the selected items when the close button is pressed. My application uses |
child: contextualAppBar, | ||
), | ||
], | ||
return Scaffold( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a reason the contextual appbar was stacked. The reason being that you can have multiple contextual appbar. Run the "Whatsapp" sample code to see what i mean here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So to avoid the issue I described, "where ContextualActionBar
was calling Scaffold.of(context)
(contextual_action_bar.dart line 216) but since it was a sibling in the Stack
, it could not find the correct Scaffold
", it looks like you wrap everything in another Scaffold
? I wonder if there is a way to avoid wrapping it with another Scaffold
.
import '../controller/items_controller.dart'; | ||
import '../typedef/handle_items.dart'; | ||
|
||
class ContextualCloseAction<T> extends StatelessWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the usecase for this ContextualCloseAction?. The material design guideline doesn't have this specification. Personally i will prefer a callback to handle this or better still use
ContextualAction instead of create an entirely new type of widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So initially I tried to just pass HandleItems<T>
, but the type was getting erased (sorry, not an expert in Dart but that appears to be what was happening). Wrapping it in ContextualAction<T>
got rid of that issue, but if you know of a way to prevent the type from being erased, definitely would like to go that route. The use case for this is simply to do an action on the list of selected items when the close button is selected, just like a ContextualAction
does.
Closing this as I've added a few things that are custom to my needs. |
The new version of
Scaffold
in flutter does not have anullOk
parameter, so I removed that.I also ran into an issue where
ContextualActionBar
was callingScaffold.of(context)
but since it was a sibling in theStack
, it could not find the correctScaffold
. I updated this so it is within theScaffold
, and theScaffold
builds either theappBar
orcontextualAppBar
depending on ifActionMode
is enabled or not.