Quellcode durchsuchen

1、CustomPage的刷新顺序修改

2、Custom Widget组件的刷新
tags/0.0.17+2^0
PH2 vor 3 Jahren
Ursprung
Commit
35c387c411
14 geänderte Dateien mit 193 neuen und 195 gelöschten Zeilen
  1. +1
    -1
      lib/pages/custom_page/bloc/custom_item_page_bloc.dart
  2. +3
    -0
      lib/pages/custom_page/bloc/custom_item_page_state.dart
  3. +12
    -4
      lib/pages/custom_page/custom_item_page.dart
  4. +3
    -1
      lib/widgets/custom/multi_nav/bloc/custom_quick_entry_bloc.dart
  5. +1
    -9
      lib/widgets/custom/multi_nav/bloc/custom_quick_entry_event.dart
  6. +8
    -8
      lib/widgets/custom/multi_nav/bloc/custom_quick_entry_repository.dart
  7. +5
    -4
      lib/widgets/custom/multi_nav/bloc/custom_quick_entry_state.dart
  8. +99
    -92
      lib/widgets/custom/multi_nav/custom_quick_entry.dart
  9. +1
    -1
      lib/widgets/custom/notice/bloc/custom_notice_bloc.dart
  10. +2
    -2
      lib/widgets/custom/notice/bloc/custom_notice_repository.dart
  11. +34
    -27
      lib/widgets/custom/notice/custom_notice_widget.dart
  12. +1
    -1
      lib/widgets/custom/slide_banner/bloc/custom_slide_banner_bloc.dart
  13. +1
    -1
      lib/widgets/custom/slide_banner/bloc/custom_slide_banner_repository.dart
  14. +22
    -44
      lib/widgets/custom/slide_banner/custom_slide_banner.dart

+ 1
- 1
lib/pages/custom_page/bloc/custom_item_page_bloc.dart Datei anzeigen

@@ -61,8 +61,8 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
Stream<CustomItemPageState> _mapRefreshEventToState(CustomItemPageRefreshEvent event) async* {
var netStyle = await repository.fetchNetStyle();
if (!EmptyUtil.isEmpty(netStyle)) {
yield CustomItemPageRefreshSuccessState();
yield CustomItemPageLoadedState(model: netStyle);
yield CustomItemPageRefreshSuccessState();
} else {
yield CustomItemPageRefreshErrorState();
yield CustomItemPageErrorState();


+ 3
- 0
lib/pages/custom_page/bloc/custom_item_page_state.dart Datei anzeigen

@@ -28,6 +28,9 @@ class CustomItemPageLoadSuccessState extends CustomItemPageState {}
/// 上拉更多失败
class CustomItemPageLoadErrorState extends CustomItemPageState {}

/// 没有更多数据的情况
class CustomItemPageNoMoreDataState extends CustomItemPageState {}

/// 其他错误
class CustomItemPageErrorState extends CustomItemPageState {}



+ 12
- 4
lib/pages/custom_page/custom_item_page.dart Datei anzeigen

@@ -89,10 +89,6 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
/// 刷新
void _refreshEvent() {
BlocProvider.of<CustomItemPageBloc>(context).add(CustomItemPageRefreshEvent());

///刷新页面

refreshPage();
}

/// 下拉更多
@@ -129,22 +125,34 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
return BlocConsumer<CustomItemPageBloc, CustomItemPageState>(
listener: (context, state) {},
buildWhen: (prev, current) {
/// 下拉刷新成功
if (current is CustomItemPageRefreshSuccessState) {
_refreshController?.refreshCompleted(resetFooterState: true);
///刷新页面
refreshPage();
return false;
}
/// 下拉刷新出错
if (current is CustomItemPageRefreshErrorState) {
_refreshController?.refreshFailed();
return false;
}
/// 上拉加载数据成功
if (current is CustomItemPageLoadSuccessState) {
_refreshController?.loadComplete();
return false;
}
/// 上拉加载数据出错
if (current is CustomItemPageLoadErrorState) {
_refreshController?.loadNoData();
return false;
}
/// 上拉加载没有更多数据
if (current is CustomItemPageNoMoreDataState) {
_refreshController?.loadNoData();
return false;
}
/// 数据加载出错
if (current is CustomItemPageErrorState) {
return false;
}


+ 3
- 1
lib/widgets/custom/multi_nav/bloc/custom_quick_entry_bloc.dart Datei anzeigen

@@ -4,6 +4,7 @@ import 'dart:math';
import 'package:bloc/bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:zhiying_comm/util/empty_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

import './bloc.dart';

@@ -25,8 +26,9 @@ class CustomQuickEntryBloc extends Bloc<CustomQuickEntryEvent, CustomQuickEntryS
/// 初始化
Stream<CustomQuickEntryState> _mapHomeQuickEntryInitToState(CustomQuickEntryInitEvent event) async* {
/// 获取父页面传进来的数据
var parentData = await repository.fetchPreantData(event: event);
var parentData = repository.fetchParentData(model: event?.model);
if (!EmptyUtil.isEmpty(parentData)) {
Logger.log('多言导航 == ' + parentData?.toJson()?.toString());
yield CustomQuickEntryLoadedState(model: parentData);
} else {
yield CustomQuickEntryErrorState();


+ 1
- 9
lib/widgets/custom/multi_nav/bloc/custom_quick_entry_event.dart Datei anzeigen

@@ -1,10 +1,5 @@
import 'package:equatable/equatable.dart';

abstract class CustomQuickEntryEvent extends Equatable {
abstract class CustomQuickEntryEvent {
const CustomQuickEntryEvent();

@override
List<Object> get props => [];
}

/// 初始事件
@@ -12,7 +7,4 @@ class CustomQuickEntryInitEvent extends CustomQuickEntryEvent {
final Map<String, dynamic> model;

const CustomQuickEntryInitEvent({this.model});

@override
List<Object> get props => [this.model];
}

+ 8
- 8
lib/widgets/custom/multi_nav/bloc/custom_quick_entry_repository.dart Datei anzeigen

@@ -10,11 +10,11 @@ import 'custom_quick_entry_event.dart';

class CustomQuickEntryRepository {
/// 获取数据
Future<CustomQuickEntryModel> fetchData({@required CustomQuickEntryInitEvent event}) async {
Future<CustomQuickEntryModel> fetchData({@required Map<String, dynamic> model}) async {
try {
var result = await NetUtil.post('/api/v1/mod/${event.model['mod_id']}',
var result = await NetUtil.post('/api/v1/mod/${model['mod_id']}',
params: {
'ids': [event.model['mod_id']]
'ids': [model['mod_id']]
},
cache: true,
method: NetMethod.GET);
@@ -31,9 +31,9 @@ class CustomQuickEntryRepository {
}

/// 获取父页面传进来的数据
Future<CustomQuickEntryModel> fetchPreantData({@required CustomQuickEntryInitEvent event}) async {
CustomQuickEntryModel fetchParentData({@required Map<String, dynamic> model}) {
try {
String jsonStr = event.model['data'];
String jsonStr = model['data'];
return CustomQuickEntryModel.fromJson(json.decode(jsonStr));
} catch (e, s) {
Logger.error(e, s);
@@ -42,10 +42,10 @@ class CustomQuickEntryRepository {
}

/// 获取缓存数据
Future<CustomQuickEntryModel> fetchCachedData({@required CustomQuickEntryInitEvent event}) async {
Future<CustomQuickEntryModel> fetchCachedData({@required Map<String, dynamic> model}) async {
try {
var result = await NetUtil.getRequestCachedData('/api/v1/mod/${event.model['mod_id']}', params: {
'ids': [event.model['mod_id']]
var result = await NetUtil.getRequestCachedData('/api/v1/mod/${model['mod_id']}', params: {
'ids': [model['mod_id']]
});
if (!EmptyUtil.isEmpty(result)) {
return _getHomeQuickEntryModel(result);


+ 5
- 4
lib/widgets/custom/multi_nav/bloc/custom_quick_entry_state.dart Datei anzeigen

@@ -18,12 +18,13 @@ class InitialCustomQuickEntryState extends CustomQuickEntryState {

/// 加载数据完毕
class CustomQuickEntryLoadedState extends CustomQuickEntryState {
final CustomQuickEntryModel model;

const CustomQuickEntryLoadedState({@required this.model});
CustomQuickEntryModel model;
CustomQuickEntryLoadedState({@required this.model});

// @override
// List<Object> get props => [this.model];
@override
List<Object> get props => [this.model];
bool operator == (Object other) => false;
}

/// 加载缓存数据


+ 99
- 92
lib/widgets/custom/multi_nav/custom_quick_entry.dart Datei anzeigen

@@ -2,7 +2,6 @@ import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
@@ -11,83 +10,96 @@ import 'custom_quick_entry_sk.dart';
import 'model/custom_quick_entry_model.dart';
import 'bloc/bloc.dart';

class CustomQuickEntry extends StatelessWidget {
class CustomQuickEntry extends StatefulWidget {
final Map<String, dynamic> model;

const CustomQuickEntry(this.model);
const CustomQuickEntry(this.model, {Key key}) : super(key: key);

@override
_CustomQuickEntryState createState() => _CustomQuickEntryState();
}

class _CustomQuickEntryState extends BaseWidgetState<CustomQuickEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {


CustomQuickEntryModel model;
CustomQuickEntryRepository _repository;

@override
bool get wantKeepAlive => true;

@override
void refreshWidget(String value) {
setState(() {
Logger.log('多言导航 ===== ' + widget?.model?.toString());
model = _repository.fetchParentData(model: widget?.model);
});
}

@override
void initState() {
_repository = CustomQuickEntryRepository();
model = _repository.fetchParentData(model: widget?.model);
super.initState();
}

@override
void dispose() {
model = null;
_repository = null;
super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocProvider<CustomQuickEntryBloc>(
create: (_) {
return CustomQuickEntryBloc(repository: CustomQuickEntryRepository())..add(CustomQuickEntryInitEvent(model: model));
},
child: _CustomQuickEntryContainer(model),
);
/// 空视图
if (EmptyUtil.isEmpty(model)) {
return CustomQuickEntrySkeleton();
}
if (model.isShowCategory == "1") { // 有分类
return CustomQuickCateEntry(model: model);
} else { // 无分类
return CustomQuickNormalEntry(model: model);
}
}
}

class _CustomQuickEntryContainer extends StatefulWidget {
final Map<String, dynamic> model;
}

_CustomQuickEntryContainer(this.model, {Key key}) : super(key: key);
///
/// 无分类多眼导航
///
class CustomQuickNormalEntry extends StatefulWidget {
CustomQuickEntryModel model;
CustomQuickNormalEntry({this.model});

@override
__CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState();
_CustomQuickNormalEntryState createState() => _CustomQuickNormalEntryState();
}

class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntryContainer> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
class _CustomQuickNormalEntryState extends State<CustomQuickNormalEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
SwiperController _controller;

/// Icon点击事件
void _itemIconClick(ListStyle model) {
print("item type = ${model.skipIdentifier}");
// Navigator.push(context, CupertinoPageRoute(builder: (_) => CommonPage(null)));
RouterUtil.route(model, model.toJson(), context);
}

SwiperController _controller;

@override
void initState() {
_controller = SwiperController();
print(widget?.model);
super.initState();
}

@override
void dispose() {
_controller?.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocConsumer<CustomQuickEntryBloc, CustomQuickEntryState>(
listener: (context, state) {},
buildWhen: (prev, current) {
if (prev is CustomQuickEntryLoadedState) {
return false;
}
return true;
},
builder: (context, state) {
print("构建");
if (state is CustomQuickEntryCachedState) {
return _getMainWidget(state.model);
}
if (state is CustomQuickEntryLoadedState) {
if (state.model.isShowCategory == "1") {
return CustomQuickCateEntry(model: state.model);
} else {
return _getMainWidget(state.model);
}
}
if (state is CustomQuickEntryErrorState) {
return Container();
}
return CustomQuickEntrySkeleton();
},
);
return _getMainWidget(widget?.model);
}

Widget _getMainWidget(CustomQuickEntryModel model) {
@@ -261,15 +273,15 @@ class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntry
/// 行的数据
Widget _getRowWidget(
{double titleHeight,
double iconHeight,
int totalPage,
int currentPage,
int columSize,
int totalRowSize,
int totalDataSize,
CustomQuickEntryModel model,
int currentRow,
double itemHeight}) {
double iconHeight,
int totalPage,
int currentPage,
int columSize,
int totalRowSize,
int totalDataSize,
CustomQuickEntryModel model,
int currentRow,
double itemHeight}) {
List itemList = [];
for (int i = 0; i < columSize; i++) {
itemList.add(i);
@@ -299,16 +311,16 @@ class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntry
/// item 的数据
Widget _getColumWidget(
{double titleHeight,
double iconHeight,
int totalPage,
int currentPage,
int columSize,
int totalRowSize,
int totalDataSize,
CustomQuickEntryModel model,
int currentRow,
int currentColum,
double itemHeight}) {
double iconHeight,
int totalPage,
int currentPage,
int columSize,
int totalRowSize,
int totalDataSize,
CustomQuickEntryModel model,
int currentRow,
int currentColum,
double itemHeight}) {
// 当前index = 当前的页数+1 * 当前的行数 + 当前的列数
// int currentIndex = (currentPage + 1) * currentRow + currentColum + currentRow*columSize;
// int currentIndex = currentPage != 0 ? currentPage * (columSize * totalRowSize) + columSize + currentRow * columSize :
@@ -447,33 +459,15 @@ class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntry
});
}

@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;

@override
void refreshWidget(String value) {
setState(() {});
}
bool get wantKeepAlive => true;
}


///
/// 图片build 优化
/// 有分类多眼导航
///
class MyNetWorkImage extends StatelessWidget {
final String imgUrl;
final double width;

const MyNetWorkImage(this.imgUrl, {this.width = 40});

@override
Widget build(BuildContext context) {
return RepaintBoundary(
child: CachedNetworkImage(width: width, imageUrl: imgUrl),
);
}
}

class CustomQuickCateEntry extends StatefulWidget {
final CustomQuickEntryModel model;

@@ -483,7 +477,8 @@ class CustomQuickCateEntry extends StatefulWidget {
_CustomQuickCateEntryState createState() => _CustomQuickCateEntryState();
}

class _CustomQuickCateEntryState extends BaseWidgetState<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {

TabController tabController;

bool isOnTap = false;
@@ -980,11 +975,6 @@ class _CustomQuickCateEntryState extends BaseWidgetState<CustomQuickCateEntry> w

@override
bool get wantKeepAlive => true;

@override
void refreshWidget(String value) {
BlocProvider.of<CustomQuickEntryBloc>(context).add(CustomQuickEntryInitEvent(model: widget?.model?.toJson()));
}
}

class PageItem {
@@ -994,3 +984,20 @@ class PageItem {

List<ListStyle> listStyle;
}

///
/// 图片build 优化
///
class MyNetWorkImage extends StatelessWidget {
final String imgUrl;
final double width;

const MyNetWorkImage(this.imgUrl, {this.width = 40});

@override
Widget build(BuildContext context) {
return RepaintBoundary(
child: CachedNetworkImage(width: width, imageUrl: imgUrl),
);
}
}

+ 1
- 1
lib/widgets/custom/notice/bloc/custom_notice_bloc.dart Datei anzeigen

@@ -21,7 +21,7 @@ class CustomNoticeBloc extends Bloc<CustomNoticeEvent, CustomNoticeState> {

/// 初始化
Stream<CustomNoticeState> _mapInitEventToState(CustomNoticeInitEvent event) async* {
var parentData = await repository.fetchParentData(event);
var parentData = repository.fetchParentData(event?.model);
if(!EmptyUtil.isEmpty(parentData))
yield CustomNoticeLoadedState(model: parentData);
else


+ 2
- 2
lib/widgets/custom/notice/bloc/custom_notice_repository.dart Datei anzeigen

@@ -4,9 +4,9 @@ import 'bloc.dart';

class CustomNoticeRepository {
/// 获取父页面的数据
Future<CustomNoticeModel> fetchParentData(CustomNoticeInitEvent event) async {
CustomNoticeModel fetchParentData(final Map<String, dynamic> model) {
try {
String jsonStr = event.model['data'];
String jsonStr = model['data'];
return CustomNoticeModel.fromJson(jsonDecode(jsonStr));
} catch (e) {
Logger.log(e);


+ 34
- 27
lib/widgets/custom/notice/custom_notice_widget.dart Datei anzeigen

@@ -6,32 +6,24 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'bloc/bloc.dart';
import 'custom_notice_sk.dart';
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart';

///
/// 公告滚动widget
///
class CustomNoticeWidget extends StatelessWidget {
class CustomNoticeWidget extends StatefulWidget {
final Map<String, dynamic> model;

const CustomNoticeWidget(this.model);

@override
Widget build(BuildContext context) {
return BlocProvider<CustomNoticeBloc>(
create: (_) =>
CustomNoticeBloc(repository: CustomNoticeRepository())
..add(CustomNoticeInitEvent(model: model)),
child: _CustomNoticeWidgetContainer(),
);
}
_CustomNoticeWidgetState createState() => _CustomNoticeWidgetState();
}

class _CustomNoticeWidgetContainer extends StatefulWidget {
@override
_CustomNoticeWidgetContainerState createState() => _CustomNoticeWidgetContainerState();
}
class _CustomNoticeWidgetState extends BaseWidgetState<CustomNoticeWidget> {

CustomNoticeModel model;
CustomNoticeRepository _repository;

class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContainer> {
/// 子item点击事件
void _itemOnClick(CustomNoticeModel model) {
if (pageIndex == model.listStyle.length) {
@@ -48,20 +40,33 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain
RouterUtil.route(model, model.toJson(), context);
}

@override
void refreshWidget(String value) {
setState(() {
model = _repository.fetchParentData(widget?.model);
});
}

@override
void initState() {
_repository = new CustomNoticeRepository();
model = _repository.fetchParentData(widget?.model);
super.initState();
}

@override
void dispose() {
model = null;
_repository = null;
super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocConsumer<CustomNoticeBloc, CustomNoticeState>(
listener: (context, state) {},
buildWhen: (prev, current) {
return true;
},
builder: (context, state) {
if (state is CustomNoticeLoadedState) {
return _getMainWidget(state?.model);
}
return CustomNoticeSkeleton();
},
);
if (!EmptyUtil.isEmpty(model))
return _getMainWidget(model);
else
return CustomNoticeSkeleton();
}

/// 主体页面
@@ -138,8 +143,10 @@ class _CustomNoticeWidgetContainerState extends State<_CustomNoticeWidgetContain
),
);
}

}


// 上下滚动的消息轮播
class MarqueeWidget extends StatefulWidget {
int count; // 子视图数量


+ 1
- 1
lib/widgets/custom/slide_banner/bloc/custom_slide_banner_bloc.dart Datei anzeigen

@@ -26,7 +26,7 @@ class CustomSlideBannerBloc extends Bloc<CustomSlideBannerEvent, CustomSlideBann

/// 初始化
Stream<CustomSlideBannerState> _mapInitEventToState(CustomBannerInitEvent event) async* {
var parent = await repository.fetchPreantData(event.model);
var parent = repository.fetchParentData(event.model);
if (!EmptyUtil.isEmpty(parent)) {
yield HomeSlideBannerLoadedState(datas: parent);
return;


+ 1
- 1
lib/widgets/custom/slide_banner/bloc/custom_slide_banner_repository.dart Datei anzeigen

@@ -19,7 +19,7 @@ class CustomSlideBannerRepository {
}

/// 获取父页面传进来的数据
Future<CustomSlideBannerModel> fetchPreantData(@required Map<String, dynamic> model) async {
CustomSlideBannerModel fetchParentData(@required Map<String, dynamic> model) {
try {
if (!EmptyUtil.isEmpty(model)) {
return CustomSlideBannerModel.fromJson(jsonDecode(model['data']));


+ 22
- 44
lib/widgets/custom/slide_banner/custom_slide_banner.dart Datei anzeigen

@@ -1,7 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';
@@ -10,6 +9,7 @@ import 'bloc/bloc.dart';
import 'bloc/custom_slide_banner_repository.dart';
import 'custom_slide_banner_sk.dart';
import 'model/custom_slide_banner_model.dart';
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart';

///
/// 可滑动 banner 轮播图
@@ -23,71 +23,48 @@ class CustomSlideBanner extends StatefulWidget {
_CustomSlideBannerState createState() => _CustomSlideBannerState();
}

class _CustomSlideBannerState extends State<CustomSlideBanner> {
@override
Widget build(BuildContext context) {
return BlocProvider<CustomSlideBannerBloc>(
create: (_) => CustomSlideBannerBloc(repository: CustomSlideBannerRepository())..add(CustomBannerInitEvent(model: widget?.model)),
child: CustomSlideBannerContainer(),
);
}
}
class _CustomSlideBannerState extends BaseWidgetState<CustomSlideBanner> {

class CustomSlideBannerContainer extends StatefulWidget {
@override
_CustomSlideBannerContainerState createState() => _CustomSlideBannerContainerState();
}
CustomSlideBannerRepository _repository;
CustomSlideBannerModel model;
SwiperController _swiperController;

class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer> {
/// 子元素点击事件
void _itemOnClick(IndexCarouselList model) {
print('点击了 $model');
RouterUtil.route(model, model.toJson(), context);
// Navigator.push(context, CupertinoPageRoute(builder: (_) => VipCenterPage(null)));
}

SwiperController _swiperController;

@override
void initState() {
_swiperController = SwiperController();
_repository = CustomSlideBannerRepository();
model = _repository.fetchParentData(widget?.model);
super.initState();
}

@override
void refreshWidget(String value) {
setState(() {
model = _repository.fetchParentData(widget?.model);
});
}

@override
void dispose() {
_swiperController.stopAutoplay();
_swiperController?.stopAutoplay();
_swiperController?.dispose();
_repository = null;
model = null;
super.dispose();
}

@override
Widget build(BuildContext context) {
return BlocConsumer<CustomSlideBannerBloc, CustomSlideBannerState>(
listener: (BuildContext context, CustomSlideBannerState state) {
if (state is HomeSlideBannerLoadError) {
print('数据加载出错');
}
},
buildWhen: (previous, current) {
/// 数据加载出错不进行build
if (current is HomeSlideBannerLoadError) {
return false;
}
return true;
},
builder: (context, state) {
print('currente state = $state');
if (state is HomeSlideBannerLoadedState) {
return _getMainWidget(state.datas);
}
if (state is CustomSlideBannerCachedState) {
return _getMainWidget(state.datas);
}
// 骨架屏
return CustomSlideBannerSkeleton();
},
);
if (!EmptyUtil.isEmpty(model))
return _getMainWidget(model);
else
return CustomSlideBannerSkeleton();
}

Widget _getMainWidget(CustomSlideBannerModel datas) {
@@ -260,3 +237,4 @@ class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer>
margin: const EdgeInsets.only(), builder: DotSwiperPaginationBuilder(color: HexColor.fromHex(unselectColor), activeColor: HexColor.fromHex(selectColor), size: 8, activeSize: 8));
}
}


Laden…
Abbrechen
Speichern