Files
lunasea/lib/core/ui/will_pop_scope.dart
2022-01-02 15:57:46 -05:00

21 lines
581 B
Dart

import 'package:flutter/material.dart';
class LunaWillPopScope extends WillPopScope {
LunaWillPopScope({
Key? key,
required GlobalKey<ScaffoldState> scaffoldKey,
required Widget child,
}) : super(
key: key,
onWillPop: () async {
if (scaffoldKey.currentState?.hasDrawer ?? false) {
if (scaffoldKey.currentState?.isDrawerOpen ?? false) return true;
scaffoldKey.currentState?.openDrawer();
return false;
}
return true;
},
child: child,
);
}