Skip to content

Commit 03f4f57

Browse files
committed
fix: restoring branch
nslogx#182
1 parent 3dcffd5 commit 03f4f57

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [3.0.6] - 2022.08.13
2+
3+
* fixed [#178](https://github.com/nslogx/flutter_easyloading/issues/178)
4+
* fixed [#178](https://github.com/nslogx/flutter_easyloading/issues/114)
5+
16
## [3.0.5] - 2022.05.23
27

38
* 🎉 It's support flutter 3.0 and previous version now
@@ -108,4 +113,4 @@
108113

109114
## [0.0.1] - 2019.12.23
110115

111-
* init
116+
* init

README-zh_CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ EasyLoading.instance
216216

217217
感谢 [flutter_spinkit](https://github.com/jogboms/flutter_spinkit) ❤️
218218

219+
感谢 [back_button_interceptor](https://github.com/marcglasberg/back_button_interceptor) ❤️
220+
219221
感谢 [JetBrains Open Source](https://www.jetbrains.com/community/opensource/#support) 提供支持
220222

221-
[<img src="https://raw.githubusercontent.com/nslogx/flutter_easyloading/master/images/jetbrains.png" width=200 height=112/>](https://www.jetbrains.com/?from=FlutterEasyLoading)
223+
[<img src="https://raw.githubusercontent.com/nslogx/flutter_easyloading/master/images/jetbrains.png" width=200 height=112/>](https://www.jetbrains.com/?from=FlutterEasyLoading)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ example: 👉 [Custom Animation](https://github.com/nslogx/flutter_easyloading/b
217217

218218
Thanks to [flutter_spinkit](https://github.com/jogboms/flutter_spinkit) ❤️
219219

220+
Thanks to [back_button_interceptor](https://github.com/marcglasberg/back_button_interceptor) ❤️
221+
220222
Supported by [JetBrains Open Source](https://www.jetbrains.com/community/opensource/#support)
221223

222224
[<img src="https://raw.githubusercontent.com/nslogx/flutter_easyloading/master/images/jetbrains.png" width=200 height=112/>](https://www.jetbrains.com/?from=FlutterEasyLoading)
223-

lib/src/easy_loading.dart

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'dart:async';
2424
import 'dart:math';
2525

2626
import 'package:flutter/material.dart';
27+
import 'package:back_button_interceptor/back_button_interceptor.dart';
2728

2829
import './widgets/container.dart';
2930
import './widgets/progress.dart';
@@ -253,6 +254,13 @@ class EasyLoading {
253254
bool? dismissOnTap,
254255
}) {
255256
Widget w = indicator ?? (_instance.indicatorWidget ?? LoadingIndicator());
257+
258+
final isIgnoringBackButton = !EasyLoadingTheme.ignoring(maskType);
259+
260+
if (isIgnoringBackButton) {
261+
BackButtonInterceptor.add(_backButtonInterceptor);
262+
}
263+
256264
return _instance._show(
257265
status: status,
258266
maskType: maskType,
@@ -287,6 +295,12 @@ class EasyLoading {
287295
key: _progressKey,
288296
value: value,
289297
);
298+
final isIgnoringBackButton = !EasyLoadingTheme.ignoring(maskType);
299+
300+
if (isIgnoringBackButton) {
301+
BackButtonInterceptor.add(_backButtonInterceptor);
302+
}
303+
290304
_instance._show(
291305
status: status,
292306
maskType: maskType,
@@ -390,7 +404,15 @@ class EasyLoading {
390404
}) {
391405
// cancel timer
392406
_instance._cancelTimer();
393-
return _instance._dismiss(animation);
407+
return _instance._dismiss(animation).whenComplete(
408+
() {
409+
final isIgnoringBackButton = !EasyLoadingTheme.ignoring(null);
410+
411+
if (!isIgnoringBackButton) return;
412+
413+
BackButtonInterceptor.remove(_backButtonInterceptor);
414+
},
415+
);
394416
}
395417

396418
/// add loading status callback
@@ -520,4 +542,10 @@ class EasyLoading {
520542
_timer?.cancel();
521543
_timer = null;
522544
}
545+
546+
static bool _backButtonInterceptor(
547+
bool stopDefaultButtonEvent,
548+
RouteInfo routeInfo,
549+
) =>
550+
true;
523551
}

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: flutter_easyloading
22
description: A clean and lightweight loading/toast widget for Flutter, Easy to use without context, Support iOS、Android and Web
3-
version: 3.0.5
3+
version: 3.0.6
44
homepage: https://github.com/nslogx/flutter_easyloading
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"
88

99
dependencies:
10+
back_button_interceptor: ^6.0.1
1011
flutter:
1112
sdk: flutter
1213

@@ -16,4 +17,4 @@ dev_dependencies:
1617
flutter_test:
1718
sdk: flutter
1819

19-
flutter:
20+
flutter:

0 commit comments

Comments
 (0)