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

Fix Scaffold.of(context) calls and update Scaffold constructors #4

Closed
wants to merge 7 commits into from

Conversation

percula
Copy link

@percula percula commented Dec 18, 2020

The new version of Scaffold in flutter does not have a nullOk parameter, so I removed that.

I also ran into an issue where ContextualActionBar was calling Scaffold.of(context) but since it was a sibling in the Stack, it could not find the correct Scaffold. I updated this so it is within the Scaffold, and the Scaffold builds either the appBar or contextualAppBar depending on if ActionMode is enabled or not.

@percula
Copy link
Author

percula commented Dec 19, 2020

I also added the option for action to be taken on the selected items when the close button is pressed. My application uses LongPressDraggable so I have to implement selection and deselection myself. This allows me to take advantage of a highlighted observable value I already am using, rather than rebuilding every selected and deselected widget when the ActionMode is enabled/disabled.

child: contextualAppBar,
),
],
return Scaffold(
Copy link
Owner

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.

Copy link
Author

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 {
Copy link
Owner

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.

Copy link
Author

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.

@percula
Copy link
Author

percula commented Jan 17, 2021

Closing this as I've added a few things that are custom to my needs.

@percula percula closed this Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants