You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
501 B
Dart

import 'package:flutter/cupertino.dart';
class BackButtonNav extends StatelessWidget {
final BuildContext context;
final Widget child;
const BackButtonNav({super.key, required this.context, required this.child});
Future<bool> _handleWillPop() async {
if (Navigator.canPop(context)) {
Navigator.pop(context);
return false;
}
return false;
}
@override
Widget build(BuildContext context) {
return WillPopScope(onWillPop: _handleWillPop, child: child);
}
}