From cbb4e1cc1142a5a5e1f944e73b637e975660ed6e Mon Sep 17 00:00:00 2001 From: weilu Date: Sun, 12 Nov 2023 16:03:21 +0800 Subject: [PATCH] Enable strict-inference --- analysis_options.yaml | 1 + lib/demo/lottie/lottie_demo.dart | 6 +++--- .../overlay/bottom_navigation/my_bottom_navigation_bar.dart | 2 +- lib/goods/widgets/goods_size_dialog.dart | 2 +- lib/goods/widgets/goods_sort_bottom_sheet.dart | 2 +- lib/goods/widgets/goods_sort_menu.dart | 2 +- lib/net/dio_utils.dart | 6 +++--- lib/order/widgets/pay_type_dialog.dart | 2 +- lib/routers/fluro_navigator.dart | 2 +- lib/shop/page/shop_page.dart | 2 +- lib/shop/page/shop_setting_page.dart | 4 ++-- lib/shop/widgets/pay_type_dialog.dart | 2 +- lib/shop/widgets/price_input_dialog.dart | 2 +- lib/shop/widgets/range_price_input_dialog.dart | 2 +- lib/shop/widgets/send_type_dialog.dart | 2 +- lib/util/app_navigator.dart | 2 +- lib/widgets/my_search_bar.dart | 2 +- pubspec.yaml | 6 +++--- 18 files changed, 25 insertions(+), 24 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4823f6bb4..8726915dd 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -17,6 +17,7 @@ analyzer: language: strict-casts: true + strict-inference: true strict-raw-types: true errors: # allow self-reference to deprecated members (we do this because otherwise we have diff --git a/lib/demo/lottie/lottie_demo.dart b/lib/demo/lottie/lottie_demo.dart index bfe0ecc36..f7bdbf02d 100644 --- a/lib/demo/lottie/lottie_demo.dart +++ b/lib/demo/lottie/lottie_demo.dart @@ -145,11 +145,11 @@ class _MyTextField extends StatefulWidget { final bool obscureText; final TextInputType? keyboardType; /// 获取焦点监听 - final Function(bool isObscure)? onHasFocus; + final void Function(bool isObscure)? onHasFocus; /// 密码可见监听 - final Function(bool isObscure)? onObscureText; + final void Function(bool isObscure)? onObscureText; /// 文字输入监听 - final Function(String text)? onChanged; + final void Function(String text)? onChanged; @override _MyTextFieldState createState() => _MyTextFieldState(); diff --git a/lib/demo/overlay/bottom_navigation/my_bottom_navigation_bar.dart b/lib/demo/overlay/bottom_navigation/my_bottom_navigation_bar.dart index 53ad62dc9..06d5a0d15 100644 --- a/lib/demo/overlay/bottom_navigation/my_bottom_navigation_bar.dart +++ b/lib/demo/overlay/bottom_navigation/my_bottom_navigation_bar.dart @@ -13,7 +13,7 @@ class MyBottomNavigationBar extends StatefulWidget { /// 选中下标 final int selectedPosition; final bool isShowIndicator; - final Function(int selectedPosition) selectedCallback; + final void Function(int selectedPosition) selectedCallback; @override _MyBottomNavigationBarState createState() => _MyBottomNavigationBarState(); diff --git a/lib/goods/widgets/goods_size_dialog.dart b/lib/goods/widgets/goods_size_dialog.dart index 13ff8207c..a034eb307 100644 --- a/lib/goods/widgets/goods_size_dialog.dart +++ b/lib/goods/widgets/goods_size_dialog.dart @@ -11,7 +11,7 @@ class GoodsSizeDialog extends StatefulWidget { this.onPressed, }); - final Function(String)? onPressed; + final void Function(String)? onPressed; @override _GoodsSizeDialog createState() => _GoodsSizeDialog(); diff --git a/lib/goods/widgets/goods_sort_bottom_sheet.dart b/lib/goods/widgets/goods_sort_bottom_sheet.dart index b3b752522..77ce31a49 100644 --- a/lib/goods/widgets/goods_sort_bottom_sheet.dart +++ b/lib/goods/widgets/goods_sort_bottom_sheet.dart @@ -18,7 +18,7 @@ class GoodsSortBottomSheet extends StatefulWidget { required this.onSelected, }); - final Function(String, String) onSelected; + final void Function(String, String) onSelected; /// 临时状态 final GoodsSortProvider provider; diff --git a/lib/goods/widgets/goods_sort_menu.dart b/lib/goods/widgets/goods_sort_menu.dart index b008981fc..969e77f80 100644 --- a/lib/goods/widgets/goods_sort_menu.dart +++ b/lib/goods/widgets/goods_sort_menu.dart @@ -17,7 +17,7 @@ class GoodsSortMenu extends StatefulWidget { final List data; final int sortIndex; final double height; - final Function(int, String) onSelected; + final void Function(int, String) onSelected; @override _GoodsSortMenuState createState() => _GoodsSortMenuState(); diff --git a/lib/net/dio_utils.dart b/lib/net/dio_utils.dart index 3a7a40178..0520c8fbe 100644 --- a/lib/net/dio_utils.dart +++ b/lib/net/dio_utils.dart @@ -29,9 +29,9 @@ void configDio({ _interceptors = interceptors ?? _interceptors; } -typedef NetSuccessCallback = Function(T data); -typedef NetSuccessListCallback = Function(List data); -typedef NetErrorCallback = Function(int code, String msg); +typedef NetSuccessCallback = void Function(T data); +typedef NetSuccessListCallback = void Function(List data); +typedef NetErrorCallback = void Function(int code, String msg); /// @weilu https://github.com/simplezhli class DioUtils { diff --git a/lib/order/widgets/pay_type_dialog.dart b/lib/order/widgets/pay_type_dialog.dart index 384a19665..ea6290f55 100644 --- a/lib/order/widgets/pay_type_dialog.dart +++ b/lib/order/widgets/pay_type_dialog.dart @@ -12,7 +12,7 @@ class PayTypeDialog extends StatefulWidget { this.onPressed, }); - final Function(int, String)? onPressed; + final void Function(int, String)? onPressed; @override _PayTypeDialog createState() => _PayTypeDialog(); diff --git a/lib/routers/fluro_navigator.dart b/lib/routers/fluro_navigator.dart index ab84e5785..0d7be3e54 100644 --- a/lib/routers/fluro_navigator.dart +++ b/lib/routers/fluro_navigator.dart @@ -19,7 +19,7 @@ class NavigatorUtils { ); } - static void pushResult(BuildContext context, String path, Function(Object) function, + static void pushResult(BuildContext context, String path, void Function(Object) function, {bool replace = false, bool clearStack = false, Object? arguments}) { unfocus(); Routes.router.navigateTo(context, path, diff --git a/lib/shop/page/shop_page.dart b/lib/shop/page/shop_page.dart index 6517db1d8..4e57eef75 100644 --- a/lib/shop/page/shop_page.dart +++ b/lib/shop/page/shop_page.dart @@ -201,7 +201,7 @@ class _ShopFunctionModule extends StatelessWidget { required this.darkImage, }); - final Function(int index) onItemClick; + final void Function(int index) onItemClick; final List data; final List image; final List darkImage; diff --git a/lib/shop/page/shop_setting_page.dart b/lib/shop/page/shop_setting_page.dart index 350b54404..0c6cde614 100644 --- a/lib/shop/page/shop_setting_page.dart +++ b/lib/shop/page/shop_setting_page.dart @@ -204,7 +204,7 @@ class _ShopSettingPageState extends State { } void _goInputTextPage(BuildContext context, String title, - String hintText, String content, Function(Object?) function, + String hintText, String content, void Function(Object?) function, {TextInputType? keyboardType}) { NavigatorUtils.pushResult(context, @@ -218,7 +218,7 @@ class _ShopSettingPageState extends State { ); } - void _showInputDialog(String title, Function(String) onPressed) { + void _showInputDialog(String title, void Function(String) onPressed) { showDialog( context: context, barrierDismissible: false, diff --git a/lib/shop/widgets/pay_type_dialog.dart b/lib/shop/widgets/pay_type_dialog.dart index 6a2b49cae..1e3cb3191 100644 --- a/lib/shop/widgets/pay_type_dialog.dart +++ b/lib/shop/widgets/pay_type_dialog.dart @@ -16,7 +16,7 @@ class PayTypeDialog extends StatefulWidget { }); final List? value; - final Function(List) onPressed; + final void Function(List) onPressed; @override _PayTypeDialog createState() => _PayTypeDialog(); diff --git a/lib/shop/widgets/price_input_dialog.dart b/lib/shop/widgets/price_input_dialog.dart index ca524fd0f..3afd98f36 100644 --- a/lib/shop/widgets/price_input_dialog.dart +++ b/lib/shop/widgets/price_input_dialog.dart @@ -18,7 +18,7 @@ class PriceInputDialog extends StatefulWidget { final String? title; final double inputMaxPrice; - final Function(String) onPressed; + final void Function(String) onPressed; @override _PriceInputDialog createState() => _PriceInputDialog(); diff --git a/lib/shop/widgets/range_price_input_dialog.dart b/lib/shop/widgets/range_price_input_dialog.dart index 10e5481c8..d6ea38795 100644 --- a/lib/shop/widgets/range_price_input_dialog.dart +++ b/lib/shop/widgets/range_price_input_dialog.dart @@ -15,7 +15,7 @@ class RangePriceInputDialog extends StatefulWidget { }); final String? title; - final Function(String, String) onPressed; + final void Function(String, String) onPressed; @override _RangePriceInputDialog createState() => _RangePriceInputDialog(); diff --git a/lib/shop/widgets/send_type_dialog.dart b/lib/shop/widgets/send_type_dialog.dart index 716b3fca2..3be7badf7 100644 --- a/lib/shop/widgets/send_type_dialog.dart +++ b/lib/shop/widgets/send_type_dialog.dart @@ -13,7 +13,7 @@ class SendTypeDialog extends StatefulWidget { required this.onPressed, }); - final Function(int, String) onPressed; + final void Function(int, String) onPressed; @override _SendTypeDialog createState() => _SendTypeDialog(); diff --git a/lib/util/app_navigator.dart b/lib/util/app_navigator.dart index c3c86a6b5..01316858d 100644 --- a/lib/util/app_navigator.dart +++ b/lib/util/app_navigator.dart @@ -32,7 +32,7 @@ class AppNavigator { ); } - static void pushResult(BuildContext context, Widget scene, Function(Object?) function) { + static void pushResult(BuildContext context, Widget scene, void Function(Object?) function) { Navigator.push( context, MaterialPageRoute( diff --git a/lib/widgets/my_search_bar.dart b/lib/widgets/my_search_bar.dart index 87dc583bc..f9e6dc1a7 100644 --- a/lib/widgets/my_search_bar.dart +++ b/lib/widgets/my_search_bar.dart @@ -19,7 +19,7 @@ class MySearchBar extends StatefulWidget implements PreferredSizeWidget { final String backImg; final String hintText; - final Function(String)? onPressed; + final void Function(String)? onPressed; @override _MySearchBarState createState() => _MySearchBarState(); diff --git a/pubspec.yaml b/pubspec.yaml index 5efb19dc1..7071a4e92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,7 +40,7 @@ dependencies: # 侧滑删除 https://github.com/letsar/flutter_slidable flutter_slidable: ^3.0.0 # WebView插件 https://github.com/flutter/packages/tree/main/packages/webview_flutter - webview_flutter: 4.2.4 + webview_flutter: 4.4.1 # 处理键盘事件 https://github.com/diegoveloper/flutter_keyboard_actions keyboard_actions: ^4.2.0 # 城市选择列表 https://github.com/flutterchina/azlistview @@ -64,7 +64,7 @@ dependencies: vibration: 1.8.1 vibration_web: 1.6.5 # 获取当前设备信息 https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus - device_info_plus: 9.0.2 + device_info_plus: 9.1.0 # 桌面应用调整窗口的大小和位置 https://github.com/leanflutter/window_manager window_manager: 0.3.6 # 高德2D地图插件(支持Web) https://github.com/simplezhli/flutter_2d_amap @@ -76,7 +76,7 @@ dependencies: # 刮刮卡 https://github.com/vintage/scratcher scratcher: ^2.4.0 # 动画效果 https://github.com/xvrh/lottie-flutter - lottie: ^2.6.0 + lottie: ^2.7.0 # https://github.com/simplezhli/flutter_deer/issues/187 dependency_overrides: