Skip to content

Commit

Permalink
update: refresh page when error occurred
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward committed Apr 8, 2021
1 parent f5e0574 commit 99fbc68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/src/faraday.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Faraday {
static BuildContext? get topContext =>
_key?.currentState?.topNavigator?.currentContext;

///刷新页面
void refresh() {
_key?.currentState?.recreateLastPage();
}

///
///`Flutter Native 容器`: iOS端是指`FlutterViewController` Android端是指
///`FlutterActivity`或者`FlutterFragment`容器初始化时需要指定 `name` 以及 `arguments`
Expand Down
6 changes: 3 additions & 3 deletions lib/src/route/native_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class FaradayNativeBridgeState extends State<FaradayNativeBridge> {
_channel.setMethodCallHandler(_handler);
}

void _recreateLastPage() async {
void recreateLastPage() async {
await _channel.invokeMethod('reCreateLastPage');
if (_navigators.isNotEmpty && (_index == null)) {
_updateIndex(0);
Expand All @@ -109,7 +109,7 @@ class FaradayNativeBridgeState extends State<FaradayNativeBridge> {
@override
void reassemble() {
try {
_recreateLastPage();
recreateLastPage();
} on MissingPluginException catch (_) {
log('reCreateLastPage failed !!', level: Level.WARNING);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ class FaradayNativeBridgeState extends State<FaradayNativeBridge> {
final index = _findIndexBy(id: call.arguments);
_previousNotFoundId = index == null ? call.arguments : null;
if (_previousNotFoundId != null) {
_recreateLastPage();
recreateLastPage();
}
_updateIndex(index);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
Expand Down

0 comments on commit 99fbc68

Please sign in to comment.