-
Notifications
You must be signed in to change notification settings - Fork 15
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
Changes from 5 commits
32f61d2
62a00ef
27039f1
eeb785f
9f95ebf
42d24da
339224f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:contextualactionbar/actions/action_mode.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So initially I tried to just pass |
||
final HandleItems<T> itemsHandler; | ||
final IconData closeIcon; | ||
const ContextualCloseAction( | ||
{Key key, this.itemsHandler, this.closeIcon}) | ||
: super(key: key); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Consumer<ItemsController<T>>( | ||
builder: (BuildContext context, ItemsController<T> value, Widget child) { | ||
return IconButton( | ||
icon: Icon(closeIcon ?? Icons.close), | ||
onPressed: () { | ||
if (itemsHandler != null) { | ||
itemsHandler(value.items); | ||
} | ||
ActionMode.disable<T>(context); | ||
}); | ||
}, | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 8.0), | ||
child: Container(), | ||
), | ||
); | ||
} | ||
} |
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 callingScaffold.of(context)
(contextual_action_bar.dart line 216) but since it was a sibling in theStack
, it could not find the correctScaffold
", it looks like you wrap everything in anotherScaffold
? I wonder if there is a way to avoid wrapping it with anotherScaffold
.