From 784377b28c90c0126f11d04910f0673ff4e2eab0 Mon Sep 17 00:00:00 2001 From: Guillermo Bueno Vargas Date: Sat, 15 Jun 2024 09:59:24 +0200 Subject: [PATCH] Replace WillPopScope with PopScope, closes #331 --- example/lib/main.dart | 12 ++++++------ lib/src/speed_dial.dart | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 5006e81..e825ab3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -69,13 +69,13 @@ class _MyHomePageState extends State with TickerProviderStateMixin { ]; @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - if (isDialOpen.value) { - isDialOpen.value = false; - return false; + return PopScope( + onPopInvoked: (bool didPop) async { + if(didPop) { + if (isDialOpen.value) { + isDialOpen.value = false; + } } - return true; }, child: Scaffold( appBar: AppBar( diff --git a/lib/src/speed_dial.dart b/lib/src/speed_dial.dart index 3960075..a701438 100644 --- a/lib/src/speed_dial.dart +++ b/lib/src/speed_dial.dart @@ -492,14 +492,14 @@ class _SpeedDialState extends State @override Widget build(BuildContext context) { return (kIsWeb || !Platform.isIOS) && widget.closeDialOnPop - ? WillPopScope( + ? PopScope( child: _renderButton(), - onWillPop: () async { - if (_open) { - _toggleChildren(); - return false; + onPopInvoked: (bool didPop) async { + if (didPop) { + if (_open) { + _toggleChildren(); + } } - return true; }, ) : _renderButton();