Skip to content

Commit

Permalink
修复addEventListener函数中可能的类型转换错误 (#1703)
Browse files Browse the repository at this point in the history
08-19 17:11:17.042 22707 24893 I flutter : The following _CastError was thrown during a scheduler callback:
08-19 17:11:17.042 22707 24893 I flutter : type 'List<(String, Map<dynamic, dynamic>) => Future<dynamic>?>' is not a subtype of type
08-19 17:11:17.042 22707 24893 I flutter : 'List<(String, Map<dynamic, dynamic>?) => Future<dynamic>?>' in type cast
08-19 17:11:17.042 22707 24893 I flutter :
08-19 17:11:17.042 22707 24893 I flutter : When the exception was thrown, this was the stack:
08-19 17:11:17.042 22707 24893 I flutter : #0      FlutterBoostAppState.addEventListener (package:flutter_boost/src/flutter_boost_app.dart:653:11)
08-19 17:11:17.042 22707 24893 I flutter : #1      BoostChannel.addEventListener (package:flutter_boost/src/boost_channel.dart:34:23)
08-19 17:11:17.042 22707 24893 I flutter : #2      FlutterBoostAppState._addAppLifecycleStateEventListener (package:flutter_boost/src/flutter_boost_app.dart:119:10)
08-19 17:11:17.042 22707 24893 I flutter : #3      FlutterBoostAppState.initState.<anonymous closure> (package:flutter_boost/src/flutter_boost_app.dart:108:7)
08-19 17:11:17.042 22707 24893 I flutter : #4      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
08-19 17:11:17.042 22707 24893 I flutter : #5      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1088:9)
08-19 17:11:17.042 22707 24893 I flutter : #6      PerformanceFlutterBinding.handleDrawFrame (package:high_available/src/api/performance_flutter_binding.dart:29:11)
08-19 17:11:17.042 22707 24893 I flutter : #7      SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:863:7)
08-19 17:11:17.042 22707 24893 I flutter : (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
  • Loading branch information
0xZOne committed Aug 23, 2022
1 parent d74d0f5 commit 916eab6
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 81 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## NEXT

## 4.0.3
1. 修复`addEventListener`函数中可能的类型转换错误

## 4.0.2
1. 增加dual_screen测试案例
2. [Android]恢复detachFromFlutterEngine重载逻辑,解决空指针崩溃问题
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>

# Release Note
## 4.0.2
## 4.0.3

PS:Null-safety is already supported.

Expand Down Expand Up @@ -37,7 +37,7 @@ Open you pubspec.yaml and add the following line to dependencies:
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '4.0.2'
ref: '4.0.3'
```


Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Release Note

## 4.0.2
## 4.0.3

PS:主线已支持空安全(null-safety)

Expand Down Expand Up @@ -35,7 +35,7 @@ PS:主线已支持空安全(null-safety)
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '4.0.2'
ref: '4.0.3'
```

# 使用文档
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '4.0.2'
ref: '4.0.3'
```

之后在flutter工程下运行`flutter pub get` dart端就集成完毕了,然后可以在dart端放上一些代码,以下代码基于example3.0
Expand Down
18 changes: 9 additions & 9 deletions example/ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
@import flutter_boost;
#endif

#if __has_include(<image_picker/FLTImagePickerPlugin.h>)
#import <image_picker/FLTImagePickerPlugin.h>
#if __has_include(<image_picker_ios/FLTImagePickerPlugin.h>)
#import <image_picker_ios/FLTImagePickerPlugin.h>
#else
@import image_picker;
@import image_picker_ios;
#endif

#if __has_include(<video_player/FLTVideoPlayerPlugin.h>)
#import <video_player/FLTVideoPlayerPlugin.h>
#if __has_include(<video_player_avfoundation/FLTVideoPlayerPlugin.h>)
#import <video_player_avfoundation/FLTVideoPlayerPlugin.h>
#else
@import video_player;
@import video_player_avfoundation;
#endif

#if __has_include(<webview_flutter/FLTWebViewFlutterPlugin.h>)
#import <webview_flutter/FLTWebViewFlutterPlugin.h>
#if __has_include(<webview_flutter_wkwebview/FLTWebViewFlutterPlugin.h>)
#import <webview_flutter_wkwebview/FLTWebViewFlutterPlugin.h>
#else
@import webview_flutter;
@import webview_flutter_wkwebview;
#endif

@implementation GeneratedPluginRegistrant
Expand Down
1 change: 1 addition & 0 deletions example/lib/case/animation_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'demo_painter.dart';

class AnimationDemo extends StatefulWidget {
const AnimationDemo({Key? key}) : super(key: key);
@override
State<AnimationDemo> createState() => _AnimationDemoState();
}
Expand Down
5 changes: 3 additions & 2 deletions example/lib/case/dual_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:dual_screen/dual_screen.dart';

class DualScreen extends StatefulWidget {
const DualScreen({Key? key}) : super(key: key);
@override
State<DualScreen> createState() => _DualScreenState();
}
Expand Down Expand Up @@ -38,9 +39,9 @@ class _DualScreenState extends State<DualScreen> {
),
),
),
endPane: Material(
endPane: const Material(
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: EdgeInsets.all(16.0),
child: Center(
child: Text('This pane is visible on dual-screen devices.'),
),
Expand Down
8 changes: 4 additions & 4 deletions example/lib/case/media_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ class _MediaQueryRouteWidgetState extends State<MediaQueryRouteWidget> {

@override
void initState() {
print('initState');
debugPrint('initState');
super.initState();
}

@override
void didChangeDependencies() {
print('didChangeDependencies');
debugPrint('didChangeDependencies');
super.didChangeDependencies();
}

@override
void deactivate() {
print('deactivate');
debugPrint('deactivate');
super.deactivate();
}

@override
void dispose() {
print('[XDEBUG] - FirstFirstRouteWidget is disposing~');
debugPrint('[XDEBUG] - FirstFirstRouteWidget is disposing~');
super.dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion example/lib/case/native_view_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class NativeViewExampleState extends State<NativeViewExample> {
Expanded(child: NativeView(viewType3, hybridCompositionMode)),
Expanded(child: NativeView(viewType3, hybridCompositionMode)),
])),
Expanded(child: AnimationDemo()),
const Expanded(child: AnimationDemo()),
Expanded(
child: Row(children: [
Expanded(child: NativeView(viewType3, hybridCompositionMode)),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/case/test_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ class _TestTextFieldState extends State<TestTextField> {
_node = FocusNode();
_node!.addListener(() {
if (_node!.hasFocus) {
print('showBottomSheet');
debugPrint('showBottomSheet');
_controller = Scaffold.of(context)
.showBottomSheet<dynamic>((BuildContext ctx) => Container(
width: double.infinity,
height: 36.0,
color: Colors.deepPurple,
));
} else {
print('closeBottomSheet');
debugPrint('closeBottomSheet');
_controller!.close();
_controller = null;
}
Expand Down
8 changes: 4 additions & 4 deletions example/lib/flutter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget>
)),
onTap: () => BoostNavigator.instance.push("native").then(
(value) =>
print("Return from Native: ${value.toString()}")),
debugPrint("Return from Native: ${value.toString()}")),
),
InkWell(
child: Container(
Expand Down Expand Up @@ -219,7 +219,7 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget>
onTap: () => BoostNavigator.instance
.push("mediaquery", withContainer: withContainer)
.then((value) =>
print('xlog, mediaquery, Return Value:$value')),
debugPrint('xlog, mediaquery, Return Value:$value')),
),
InkWell(
child: Container(
Expand All @@ -246,7 +246,7 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget>
onTap: () => BoostNavigator.instance
.push("webview", withContainer: withContainer)
.then(
(value) => print('xlog, webview, Return Value:$value')),
(value) => debugPrint('xlog, webview, Return Value:$value')),
),
InkWell(
child: Container(
Expand Down Expand Up @@ -325,7 +325,7 @@ class _FlutterRouteWidgetState extends State<FlutterRouteWidget>
context,
MaterialPageRoute<dynamic>(
builder: (_) => PushWidget())).then((value) =>
print('xlog, PushWidget, Return Value: $value'));
debugPrint('xlog, PushWidget, Return Value: $value'));
},
),
InkWell(
Expand Down
30 changes: 15 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ class _MyAppState extends State<MyApp> {
'imagepick': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => ImagePickerPage(title: "xxx"));
pageBuilder: (_, __, ___) => const ImagePickerPage(title: "xxx"));
},
'interceptor': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => ImagePickerPage(title: "interceptor"));
pageBuilder: (_, __, ___) => const ImagePickerPage(title: "interceptor"));
},
'firstFirst': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
Expand All @@ -170,16 +170,16 @@ class _MyAppState extends State<MyApp> {
},
'willPop': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings, pageBuilder: (_, __, ___) => WillPopRoute());
settings: settings, pageBuilder: (_, __, ___) => const WillPopRoute());
},
'counter': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => CounterPage(title: "Counter Demo"));
pageBuilder: (_, __, ___) => const CounterPage(title: "Counter Demo"));
},
'dualScreen': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings, pageBuilder: (_, __, ___) => DualScreen());
settings: settings, pageBuilder: (_, __, ___) => const DualScreen());
},
'returnData': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
Expand Down Expand Up @@ -220,7 +220,7 @@ class _MyAppState extends State<MyApp> {

///可以在native层通过 getContainerParams 来传递参数
'flutterPage': (settings, uniqueId) {
print('flutterPage settings:$settings, uniqueId:$uniqueId');
debugPrint('flutterPage settings:$settings, uniqueId:$uniqueId');
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => FlutterRouteWidget(
Expand Down Expand Up @@ -310,12 +310,12 @@ class _MyAppState extends State<MyApp> {
'bottom_navigation': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => BottomNavigationPage());
pageBuilder: (_, __, ___) => const BottomNavigationPage());
},
'system_ui_overlay_style': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
settings: settings,
pageBuilder: (_, __, ___) => SystemUiOverlayStyleDemo());
pageBuilder: (_, __, ___) => const SystemUiOverlayStyleDemo());
},
'mediaquery': (settings, uniqueId) {
return PageRouteBuilder<dynamic>(
Expand All @@ -333,7 +333,7 @@ class _MyAppState extends State<MyApp> {
builder: (ctx) {
return BoostCacheWidget(
uniqueId: uniqueId!,
builder: (_) => FlutterRebuildDemo(),
builder: (_) => const FlutterRebuildDemo(),
);
});
},
Expand All @@ -343,7 +343,7 @@ class _MyAppState extends State<MyApp> {
builder: (ctx) {
return BoostCacheWidget(
uniqueId: uniqueId!,
builder: (_) => FlutterRebuildPageA(),
builder: (_) => const FlutterRebuildPageA(),
);
});
},
Expand All @@ -353,7 +353,7 @@ class _MyAppState extends State<MyApp> {
builder: (ctx) {
return BoostCacheWidget(
uniqueId: uniqueId!,
builder: (_) => FlutterRebuildPageB(),
builder: (_) => const FlutterRebuildPageB(),
);
});
},
Expand Down Expand Up @@ -385,22 +385,22 @@ class _MyAppState extends State<MyApp> {
class BoostNavigatorObserver extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
print('boost-didPush${route.settings.name}');
debugPrint('boost-didPush${route.settings.name}');
}

@override
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
print('boost-didPop${route.settings.name}');
debugPrint('boost-didPop${route.settings.name}');
}

@override
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
print('boost-didRemove${route.settings.name}');
debugPrint('boost-didRemove${route.settings.name}');
}

@override
void didStartUserGesture(
Route<dynamic> route, Route<dynamic>? previousRoute) {
print('boost-didStartUserGesture${route.settings.name}');
debugPrint('boost-didStartUserGesture${route.settings.name}');
}
}

0 comments on commit 916eab6

Please sign in to comment.