Open mfrischbutter opened 1 year ago
import 'package:flutter/material.dart';
import 'package:flutter_split_view/flutter_split_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(),
home: Scaffold(
body: SafeArea(
child: SplitView.material(
breakpoint: 900,
placeholder: const Text('Placeholder'),
child: Builder(builder: (context) {
return ElevatedButton(
onPressed: () {
SplitView.of(context).push(
WillPopScope(
onWillPop: () async {
SplitView.of(context).pop();
return false;
},
child: const Center(
child: Text('Next Page'),
),
),
);
},
child: const Text('Next Page'),
);
}),
),
),
),
);
}
}
Issue
Currently if you are pressing the android back button, the action does not pop the context of the SplitView, it would try to pop the context of the Navigator.
Expected Result
If you are currently inside one View after using SplitView.push(), you are pressing the back button, i would expect SplitView.pop() would be called, instead of Navigator.pop().
Hotfix
I already tried to fix it somehow with a WillPopScope, but somehow i am not able to but it inside the child or placeholder of the SplitView Widget. It does not get called. Only if the SplitView is the child, it would be get called, but i dont have the context of the SplitView in this case and can't pop the SplitView.
Solution
Add a controller to be able to control the SplitView outside of context, or try to fix the WillPopScope, so it would automatically choose the right action.