I want to disable left and right gesture navigation for 1 page ( one dart program) in my app which is 21 dart programs. I do not care about the other pages. I have not found any simple examples that work on my pixel 8 phone.
The app compiles and works fine but I cannot disable the left and right gestures on the pixel 8 phone on which I am testing. If I add the line of code
PopScope(child: Scaffold(), canPop: false);
in the widget build override, it makes no difference – the left and right gestures are still not disabled.
Here is my code for Page6.dart (with many of the 300 lines removed for simplicity)….
class Page6 extends StatefulWidget {
...(code)
@override
State<Page6> createState() => _Page6State();
}
class _Page6State extends State<Page6> {
...(code)
@override
void initState() {
...(code)
}
@override
Widget build(BuildContext context) {
PopScope(child: Scaffold(), canPop: false);
ManTrack mantrack = widget.mantrack;
RouteDataModel routeNow = widget.routeNow;
TransformationController viewTC = widget.viewTC;
print('page6.dart - build method called, ok = $ok');
t.timestamp('#3 ***** START BUILD *******');
WidgetsBinding.instance.addPostFrameCallback((_) {
t.timestamp("#999 **** BUILD COMPLETE *******");
});
if (ok && mantrack.uiShow != null) {
return Scaffold(
appBar: AppBar(
title: const Text("Tracking You"),
automaticallyImplyLeading: false,
actions: [
ElevatedButton(
child: Text('Refresh'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange,
),
onPressed: () async {
getLocationNow();
}),
ElevatedButton(
child: Text('Save'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange,
),
onPressed: () async {
p6popup2(context, routeNow, mantrack);
}),
ElevatedButton(
child: Text('Stats'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange),
onPressed: () async {
MapCornersDataModel2 mapcornersNow = widget.mapcornersNow;
GPSLocation gpsNow = widget.gpsNow;
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Page5(
mapcornersNow: mapcornersNow,
gpsNow: gpsNow,
statsNow: statsNow,
t: t,
)));
}),
ElevatedButton(
child: Text('Stop'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange,
),
onPressed: () async {
p6popup1(context, routeNow, mantrack);
})
]),
body: InteractiveViewer(
transformationController: viewTC,
minScale: 0.5,
maxScale: 100.0,
child: RawImage(
image: mantrack.uiShow,
height: double.infinity,
width: double.infinity)));
} else {
return const Center(child: CircularProgressIndicator());
}
}
}