From 339a7bb02a9c7fb4346db0379181ae3f3c72279d Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Mon, 14 Sep 2020 11:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0example=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5releas?= =?UTF-8?q?e=E6=89=93=E5=8C=85=E9=A1=B5=E9=9D=A2=E9=94=99=E8=AF=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 13 +++-- .../xcshareddata/xcschemes/Runner.xcscheme | 10 ++-- example/lib/main.dart | 25 ++++++++- lib/pages/main_page/main_page.dart | 14 ++++- .../bloc/home_slide_banner_repository.dart | 51 ++++++++++--------- 6 files changed, 73 insertions(+), 42 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 2b334b6..f22f59b 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -680,7 +680,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-11T11:58:25.076408Z", + "generated": "2020-09-14T01:30:48.161905Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index a14546a..04dccaa 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -80,7 +80,6 @@ 3CF5E07C1CDF5F802B057127 /* Pods-Runner.release.xcconfig */, E03B6CB558D0A26B049E0718 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -392,9 +391,9 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = cn.shengfen.Fm; + PRODUCT_BUNDLE_IDENTIFIER = cn.zhios.zhiying; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = shengFenFMTest; + PROVISIONING_PROFILE_SPECIFIER = cn.zhios.zhiying_dev; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -525,9 +524,9 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = cn.shengfen.Fm; + PRODUCT_BUNDLE_IDENTIFIER = cn.zhios.zhiying; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = shengFenFMTest; + PROVISIONING_PROFILE_SPECIFIER = cn.zhios.zhiying_dev; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -551,9 +550,9 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = cn.shengfen.Fm; + PRODUCT_BUNDLE_IDENTIFIER = cn.zhios.zhiying; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = shengFenFMTest; + PROVISIONING_PROFILE_SPECIFIER = cn.zhios.zhiying_dev; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..c537502 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -27,8 +27,6 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - + + - - runApp(MyApp()); +void main() { + FlutterError.onError = (FlutterErrorDetails details) { + FlutterError.dumpErrorToConsole(details); + print(details.exceptionAsString()); +// if (kReleaseMode) exit(1); + }; + runApp(MyApp()); +} class MyApp extends StatefulWidget { @override @@ -11,14 +18,28 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { + Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { + return Center( + child: Text( + "走神了~\n${error.exceptionAsString()}", + style: + Theme.of(context).textTheme.title.copyWith(color: Colors.redAccent), + ), + ); + } + @override void initState() { super.initState(); + print('初始化~~~~'); BaseWidgetRegister.init(); } @override Widget build(BuildContext context) { + ErrorWidget.builder = (FlutterErrorDetails errorDetails) { + return getErrorWidget(context, errorDetails); + }; return MaterialApp( home: HomePage(), ); diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 6b458e6..ea28ad7 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -97,7 +97,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { removeTop: true, context: context, child: SmartRefresher( - enablePullDown: false, + enablePullDown: true, enablePullUp: false, header: WaterDropHeader(), controller: _refreshController, @@ -132,12 +132,24 @@ class _MainPageContainerState extends State<_MainPageContainer> { WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); + print('item.modName ${item.modName}'); list.addAll(WidgetFactory.create( item.modName, isSliver: true, model: datas[i], )); } + print('生成列表widget个数 ${list.length}'); + if (list.length <= 0) { + list.add(SliverToBoxAdapter( + child: Container( + height: 200, + child: Center( + child: Text('暂时无数据哦~'), + ), + ), + )); + } return list; } } diff --git a/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart b/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart index 672cb31..2fe180e 100644 --- a/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart +++ b/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart @@ -1,34 +1,37 @@ - import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/model/home_slide_banner_model.dart'; -import 'package:zhiying_comm/util/net_util.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/model/home_slide_banner_model.dart'; import 'package:zhiying_comm/util/empty_util.dart'; import 'package:zhiying_comm/util/global_config.dart'; +import 'package:zhiying_comm/util/net_util.dart'; -class HomeSlideBannerRepository{ - - /// 获取缓存数据 - Future> fetchCachedDate({@required int id}) async{ - var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: {'ids': [id]}); - if(!EmptyUtil.isEmpty(cached)){ - HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); - if(null != model && !EmptyUtil.isEmpty(model.items)){ - return model.items; - } +class HomeSlideBannerRepository { + /// 获取缓存数据 + Future> fetchCachedDate( + {@required int id}) async { + var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: { + 'ids': [id] + }); + if (!EmptyUtil.isEmpty(cached)) { + HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); + if (null != model && !EmptyUtil.isEmpty(model.items)) { + return model.items; } - return null; } + return null; + } - /// 获取数据 - Future> fetchData({@required int id}) async{ - var params = await NetUtil.post('/api/v1/mod', params: {'ids': [id]}); - if(NetUtil.isSuccess(params)){ - HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); - if(null != model && !EmptyUtil.isEmpty(model.items)){ - return model.items; - } + /// 获取数据 + Future> fetchData({@required int id}) async { + var params = await NetUtil.post('/api/v1/mod', params: { + 'ids': [id] + }); + if (NetUtil.isSuccess(params)) { + HomeSlideBannerModel model = HomeSlideBannerModel.fromJson( + params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + if (null != model && !EmptyUtil.isEmpty(model.items)) { + return model.items; } - return null; } - + return null; + } }