Commit e3d587ea authored by Adam Barth's avatar Adam Barth

Move default back behavior to FlutterWidgetBinding

Previously MaterialApp was responsible for ending the activity when the
back stack was empty. However, this behavior is more general than
material. This patch moves the behavior to FlutterWidgetBinding, which
has a global view of all the binding observers.

Fixes #1086
parent 19fb068d
......@@ -86,11 +86,11 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
assert(mounted);
NavigatorState navigator = _navigator.currentState;
assert(navigator != null);
bool result = false;
navigator.openTransaction((NavigatorTransaction transaction) {
if (!transaction.pop())
activity.finishCurrentActivity();
result = transaction.pop();
});
return true;
return result;
}
void didChangeSize(Size size) => setState(() { _size = size; });
......
......@@ -77,8 +77,9 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Rendere
void handlePopRoute() {
for (BindingObserver observer in _observers) {
if (observer.didPopRoute())
break;
return;
}
activity.finishCurrentActivity();
}
void handleAppLifecycleStateChanged(ui.AppLifecycleState state) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment