aves/lib/widgets/common/behaviour/pop/scope.dart
Thibault Deckers fbc10cc6a8 #437 tv: fixes
2022-12-19 16:32:40 +01:00

23 lines
673 B
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
// as of Flutter v3.3.10, the resolution order of multiple `WillPopScope` is random
// so this widget combines multiple handlers with a guaranteed order
class AvesPopScope extends StatelessWidget {
final List<bool Function(BuildContext context)> handlers;
final Widget child;
const AvesPopScope({
super.key,
required this.handlers,
required this.child,
});
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => SynchronousFuture(handlers.fold(true, (prev, v) => prev ? v(context) : false)),
child: child,
);
}
}