Commit 3e21f1ca authored by 汪林玲's avatar 汪林玲

加入null-safety

parent 9a50195e
# xiaoxiong_price_module # 小熊有好货-好价模块
A new Flutter package project. ### 引入说明
```
price_module:
git:
url: 'git@git.xiaomanxiong.com:flutter-plugin/xiaoxiong-price-module.git'
ref: 'null-safety'
## Getting Started ```
\ No newline at end of file
This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
import 'package:flutter/foundation.dart';
class NotifyEventType { class NotifyEventType {
NotifyEventEnum eventType; NotifyEventEnum eventType;
NotifyEventType({@required this.eventType}); NotifyEventType({required this.eventType});
} }
enum NotifyEventEnum { enum NotifyEventEnum {
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
abstract class IDSAction<VM> { abstract class IDSAction<VM> {
VM vm; VM? vm;
void initState(); void initState();
......
...@@ -8,12 +8,12 @@ class DSProvider<VO extends IDSModel> extends ChangeNotifierProvider<VO> { ...@@ -8,12 +8,12 @@ class DSProvider<VO extends IDSModel> extends ChangeNotifierProvider<VO> {
final Widget Function( final Widget Function(
BuildContext context, BuildContext context,
VO value, VO value,
Widget child, Widget? child,
) builderWidget; ) builderWidget;
DSProvider.value({ DSProvider.value({
@required this.vo, required this.vo,
@required this.builderWidget, required this.builderWidget,
}) : super.value( }) : super.value(
value: vo, value: vo,
child: Consumer<VO>( child: Consumer<VO>(
......
...@@ -7,19 +7,19 @@ import 'package:provider/provider.dart'; ...@@ -7,19 +7,19 @@ import 'package:provider/provider.dart';
class DSProviderWidget<VM extends IDSModel, T extends IDSAction<VM>> extends StatefulWidget { class DSProviderWidget<VM extends IDSModel, T extends IDSAction<VM>> extends StatefulWidget {
final T dsAction; final T dsAction;
final Widget child; final Widget? child;
final Widget Function(BuildContext context,Widget child) builder; final Widget Function(BuildContext context,Widget? child) builder;
const DSProviderWidget({Key key,@required this.dsAction,@required this.builder,this.child}):super(key:key); const DSProviderWidget({Key? key,required this.dsAction,required this.builder,this.child}):super(key:key);
@override @override
_DSProviderWidgetState<VM,T> createState() => _DSProviderWidgetState<VM,T>(); _DSProviderWidgetState<VM,T> createState() => _DSProviderWidgetState<VM,T>();
} }
class _DSProviderWidgetState<VM extends IDSModel,T extends IDSAction<VM>> extends State<DSProviderWidget<VM,T>> { class _DSProviderWidgetState<VM extends IDSModel,T extends IDSAction<VM>> extends State<DSProviderWidget<VM,T>> {
T action; T? action;
Widget get _child => widget.child; Widget? get _child => widget.child;
@override @override
void initState() { void initState() {
...@@ -30,8 +30,8 @@ class _DSProviderWidgetState<VM extends IDSModel,T extends IDSAction<VM>> extend ...@@ -30,8 +30,8 @@ class _DSProviderWidgetState<VM extends IDSModel,T extends IDSAction<VM>> extend
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ChangeNotifierProvider<VM>.value( return ChangeNotifierProvider<VM?>.value(
value: action.vm, value: action!.vm,
child: Consumer<VM>( child: Consumer<VM>(
builder:(context,vm,child){ builder:(context,vm,child){
action?.initBuilder(context); action?.initBuilder(context);
......
class DSNetException implements Exception { class DSNetException implements Exception {
final String message; final String? message;
final int code; final int? code;
@pragma("vm:entry-point") @pragma("vm:entry-point")
const DSNetException({this.message = "", this.code}); const DSNetException({this.message = "", this.code});
String toString() { String toString() {
......
import 'package:flutter/material.dart';
import 'package:price_module/eventbus/notify_event_type.dart'; import 'package:price_module/eventbus/notify_event_type.dart';
import 'package:price_module/eventbus/platform_icon_event.dart'; import 'package:price_module/eventbus/platform_icon_event.dart';
import 'package:price_module/framework/action/ds_action.dart'; import 'package:price_module/framework/action/ds_action.dart';
...@@ -17,7 +16,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo> ...@@ -17,7 +16,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo>
/// 商品举报 /// 商品举报
/// [reportType] 举报类型 /// [reportType] 举报类型
/// ///
void report({String reportType}); void report({String? reportType});
/// ///
/// 用户点赞 /// 用户点赞
...@@ -34,7 +33,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo> ...@@ -34,7 +33,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo>
/// ///
/// 用户点击购买 /// 用户点击购买
/// ///
Future<TurnChainEntity> goToBuyEvent(); Future<TurnChainEntity?> goToBuyEvent();
/// ///
/// 凑单购买 /// 凑单购买
...@@ -42,7 +41,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo> ...@@ -42,7 +41,7 @@ abstract class IPriceDetailsAction<PriceDetailsVo>
/// [platform] 平台 /// [platform] 平台
/// ///
/// ///
Future<TurnChainEntity> goToBuyItemId({String itemId, String platform}); Future<TurnChainEntity?> goToBuyItemId({String? itemId, String? platform});
/// ///
/// 获取举报配置信息 /// 获取举报配置信息
...@@ -53,16 +52,16 @@ abstract class IPriceDetailsAction<PriceDetailsVo> ...@@ -53,16 +52,16 @@ abstract class IPriceDetailsAction<PriceDetailsVo>
class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
PriceDetailsService _detailsService = PriceDetailsService(); PriceDetailsService _detailsService = PriceDetailsService();
IPriceDetailsActionDelegate _actionDelegate; IPriceDetailsActionDelegate? _actionDelegate;
Map<int, dynamic> _platformIconMap; Map<int, dynamic>? _platformIconMap;
List<dynamic> _sellReportList = []; List<dynamic> _sellReportList = [];
@override @override
List<dynamic> get sellReportList => _sellReportList; List<dynamic> get sellReportList => _sellReportList;
PriceDetailsAction( PriceDetailsAction(
{Map<String, dynamic> param, IPriceDetailsActionDelegate delegate}) { {required Map<String, dynamic> param, IPriceDetailsActionDelegate? delegate}) {
eventBus.on<PlatformIconEvent>().listen((event) { eventBus.on<PlatformIconEvent>().listen((event) {
_platformIconMap = event.map; _platformIconMap = event.map;
}); });
...@@ -71,15 +70,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -71,15 +70,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
this._actionDelegate = delegate; this._actionDelegate = delegate;
this.vm = PriceDetailsVo(productId: param['productId']); this.vm = PriceDetailsVo(productId: param['productId']);
if (param['src'] != null && param['src'] is String) { if (param['src'] != null && param['src'] is String) {
this.vm.itemPic = [param['src']]; this.vm!.itemPic = [param['src']];
} }
if (param['title'] != null && param['title'] is String) { if (param['title'] != null && param['title'] is String) {
this.vm.itemTitle = param['title']; this.vm!.itemTitle = param['title'];
} }
if (param['sellReportList'] is List) { if (param['sellReportList'] is List) {
_sellReportList = List<dynamic>.from(param['sellReportList']); _sellReportList = List<dynamic>.from(param['sellReportList']);
try { try {
this.vm.reports = this.vm!.reports =
List<ReportModel>.generate(sellReportList.length, (index) { List<ReportModel>.generate(sellReportList.length, (index) {
Map<String, dynamic> sellReport = Map<String, dynamic> sellReport =
Map<String, dynamic>.from(sellReportList[index]); Map<String, dynamic>.from(sellReportList[index]);
...@@ -101,9 +100,9 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -101,9 +100,9 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
} }
@override @override
void report({String reportType}) async { void report({String? reportType}) async {
_detailsService _detailsService
.report(id: this.vm.productId, reportType: reportType) .report(id: this.vm!.productId!, reportType: reportType!)
.asStream() .asStream()
.first .first
.then((value) { .then((value) {
...@@ -123,8 +122,8 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -123,8 +122,8 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
disableLike = true; disableLike = true;
_detailsService _detailsService
.userLike( .userLike(
markId: this.vm.productId, markId: this.vm!.productId!,
platform: this.vm.platform, platform: this.vm!.platform!,
status: status ? '2' : '1') status: status ? '2' : '1')
.asStream() .asStream()
.first .first
...@@ -132,15 +131,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -132,15 +131,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
if (value['code'] == 2000) { if (value['code'] == 2000) {
if (status) { if (status) {
try { try {
this.vm.likeTimes = '${int.parse(this.vm.likeTimes) - 1}'; this.vm!.likeTimes = '${int.parse(this.vm!.likeTimes!) - 1}';
} catch (e) {} } catch (e) {}
} else { } else {
try { try {
this.vm.likeTimes = '${int.parse(this.vm.likeTimes) + 1}'; this.vm!.likeTimes = '${int.parse(this.vm!.likeTimes!) + 1}';
} catch (e) {} } catch (e) {}
} }
this.vm.isLike = !status; this.vm!.isLike = !status;
this.vm.notifyListener(true); this.vm!.notifyListener(true);
} }
}) })
.catchError((error) {}) .catchError((error) {})
...@@ -157,8 +156,8 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -157,8 +156,8 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
disableCollect = true; disableCollect = true;
_detailsService _detailsService
.userCollect( .userCollect(
itemId: this.vm.productId, itemId: this.vm!.productId!,
platform: this.vm.platform, platform: this.vm!.platform!,
status: status ? '2' : '1') status: status ? '2' : '1')
.asStream() .asStream()
.first .first
...@@ -169,15 +168,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -169,15 +168,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
} }
if (status) { if (status) {
try { try {
this.vm.collegeTimes = '${int.parse(this.vm.collegeTimes) - 1}'; this.vm!.collegeTimes = '${int.parse(this.vm!.collegeTimes!) - 1}';
} catch (e) {} } catch (e) {}
} else { } else {
try { try {
this.vm.collegeTimes = '${int.parse(this.vm.collegeTimes) + 1}'; this.vm!.collegeTimes = '${int.parse(this.vm!.collegeTimes!) + 1}';
} catch (e) {} } catch (e) {}
} }
this.vm.isFavorites = !status; this.vm!.isFavorites = !status;
this.vm.notifyListener(true); this.vm!.notifyListener(true);
} }
}) })
.catchError((error) {}) .catchError((error) {})
...@@ -188,63 +187,63 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -188,63 +187,63 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
@override @override
void initState() async { void initState() async {
this.vm.viewState = DSViewState.busy; this.vm!.viewState = DSViewState.busy;
_detailsService _detailsService
.qryProductDetails(productId: this.vm.productId) .qryProductDetails(productId: this.vm!.productId!)
.asStream() .asStream()
.first .first
.then((value) { .then((value) {
this.vm.viewState = DSViewState.idle; this.vm!.viewState = DSViewState.idle;
this.vm.itemPic = value.itemPic; this.vm!.itemPic = value.itemPic;
this.vm.itemId = value.itemId; this.vm!.itemId = value.itemId;
this.vm.platform = value.platform; this.vm!.platform = value.platform;
this.vm.platformText = _getPlatformName(int.parse(value.platform)); this.vm!.platformText = _getPlatformName(int.parse(value.platform!));
this.vm.itemTitle = value.itemTitle; this.vm!.itemTitle = value.itemTitle;
this.vm.subTitle = value.subTitle; this.vm!.subTitle = value.subTitle;
this.vm.status = value.status; this.vm!.status = value.status;
this.vm.likeTimes = value.likeTimes; this.vm!.likeTimes = value.likeTimes;
this.vm.collegeTimes = value.collegeTimes; this.vm!.collegeTimes = value.collegeTimes;
this.vm.buttonText = value.buttonText; this.vm!.buttonText = value.buttonText;
this.vm.description = value.description; this.vm!.description = value.description;
this.vm.releaseTime = value.releaseTime; this.vm!.releaseTime = value.releaseTime;
this.vm.couponText = value.couponText; this.vm!.couponText = value.couponText;
this.vm.checkText = value.checkText; this.vm!.checkText = value.checkText;
this.vm.coupons = value.coupons; this.vm!.coupons = value.coupons;
this.vm.shareUrl = value.shareUrl; this.vm!.shareUrl = value.shareUrl;
this.vm.price = value.price; this.vm!.price = value.price;
this.vm.endPrice = value.endPrice; this.vm!.endPrice = value.endPrice;
this.vm.shareMessage = value.shareMessage; this.vm!.shareMessage = value.shareMessage;
this.vm.isLike = value.isLike; this.vm!.isLike = value.isLike;
this.vm.isFavorites = value.isFavorites; this.vm!.isFavorites = value.isFavorites;
this.vm.isOverdue = value.isOverdue; this.vm!.isOverdue = value.isOverdue;
this.vm.shopTitle = value.shopTitle; this.vm!.shopTitle = value.shopTitle;
this.vm.rebate = value.rebate; this.vm!.rebate = value.rebate;
this.vm.collectOrders = value.collectOrders; this.vm!.collectOrders = value.collectOrders;
this.vm.newItemInfo = value.newItemInfo; this.vm!.newItemInfo = value.newItemInfo;
}).catchError((error) { }).catchError((error) {
this.vm.viewState = DSViewState.idle; this.vm!.viewState = DSViewState.idle;
}).catchError((error) { }).catchError((error) {
this.vm.viewState = DSViewState.error; this.vm!.viewState = DSViewState.error;
}).whenComplete(() { }).whenComplete(() {
_detailsService _detailsService
.getSellingRecommends( .getSellingRecommends(
excludeId: this.vm.productId, excludeId: this.vm!.productId,
keywords: this.vm.itemTitle, keywords: this.vm!.itemTitle,
page: 1, page: 1,
pagesize: 7, pagesize: 7,
) )
.then((value) { .then((value) {
if (value.isSuccess) { if (value.isSuccess) {
this.vm.productEntitys = value.data; this.vm!.productEntitys = value.data;
this.vm.productEntitys.forEach((ele) { this.vm!.productEntitys!.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime); ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = _getPlatformName(int.parse(ele.platform)); ele.platform = _getPlatformName(int.parse(ele.platform!));
}); });
} }
}).catchError((error) { }).catchError((error) {
print(error); print(error);
}).whenComplete(() { }).whenComplete(() {
this.vm.notifyListener(true); this.vm!.notifyListener(true);
}); });
}); });
} }
...@@ -254,19 +253,19 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -254,19 +253,19 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
/// [platform] 平台id /// [platform] 平台id
/// ///
String _getPlatformName(int platform) { String _getPlatformName(int platform) {
if (_platformIconMap != null && _platformIconMap[platform] is Map) { if (_platformIconMap != null && _platformIconMap![platform] is Map) {
Map<String, dynamic> platformMap = Map<String, dynamic> platformMap =
Map<String, dynamic>.from(_platformIconMap[platform]); Map<String, dynamic>.from(_platformIconMap![platform]);
return platformMap['name'] ?? ''; return platformMap['name'] ?? '';
} }
return ''; return '';
} }
@override @override
Future<TurnChainEntity> goToBuyEvent() async { Future<TurnChainEntity?> goToBuyEvent() async {
DSResponseObject<TurnChainEntity> resObject = await _detailsService DSResponseObject<TurnChainEntity> resObject = await _detailsService
.turnChainForItemId( .turnChainForItemId(
itemId: this.vm.itemId, platform: this.vm.platform, type: '6') itemId: this.vm!.itemId!, platform: this.vm!.platform!, type: '6')
.asStream() .asStream()
.first; .first;
if (resObject.isSuccess) { if (resObject.isSuccess) {
...@@ -276,15 +275,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -276,15 +275,15 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
} }
@override @override
Future<TurnChainEntity> goToBuyItemId({ Future<TurnChainEntity?> goToBuyItemId({
String itemId, String? itemId,
String platform, String? platform,
}) async { }) async {
if (platform == null) { if (platform == null) {
platform = this.vm.platform; platform = this.vm!.platform;
} }
DSResponseObject<TurnChainEntity> resObject = await _detailsService DSResponseObject<TurnChainEntity> resObject = await _detailsService
.turnChainForItemId(itemId: itemId, platform: platform, type: '6') .turnChainForItemId(itemId: itemId!, platform: platform!, type: '6')
.asStream() .asStream()
.first; .first;
if (resObject.isSuccess) { if (resObject.isSuccess) {
...@@ -298,5 +297,5 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> { ...@@ -298,5 +297,5 @@ class PriceDetailsAction extends IPriceDetailsAction<PriceDetailsVo> {
/// 代理类,类似接口 /// 代理类,类似接口
/// ///
abstract class IPriceDetailsActionDelegate { abstract class IPriceDetailsActionDelegate {
void showTipsMsg({@required String msg}); void showTipsMsg({required String msg});
} }
...@@ -28,15 +28,15 @@ abstract class IPriceDiscountAction<PriceDiscountVo> ...@@ -28,15 +28,15 @@ abstract class IPriceDiscountAction<PriceDiscountVo>
PriceDiscountVo get getVo; PriceDiscountVo get getVo;
} }
class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> { class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo?> {
PriceRepository _priceRepository = PriceRepository.get(); PriceRepository _priceRepository = PriceRepository.get();
Map<int, dynamic> _platformIconMap; Map<int, dynamic>? _platformIconMap;
IPriceDiscountDelegate _discountDelegate; IPriceDiscountDelegate? _discountDelegate;
Map<String, dynamic> _pageParam; Map<String, dynamic>? _pageParam;
PriceDiscountAction({ PriceDiscountAction({
IPriceDiscountDelegate delegate, IPriceDiscountDelegate? delegate,
Map<String, dynamic> pageParam, Map<String, dynamic>? pageParam,
}) { }) {
this._pageParam = pageParam; this._pageParam = pageParam;
_discountDelegate = delegate; _discountDelegate = delegate;
...@@ -61,7 +61,7 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> { ...@@ -61,7 +61,7 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
pagesize: 10, pagesize: 10,
isRefresh: true, isRefresh: true,
); );
this.vm.notifyListener(); this.vm!.notifyListener();
} }
@override @override
...@@ -85,12 +85,12 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> { ...@@ -85,12 +85,12 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
}) { }) {
currentPage = page; currentPage = page;
if (isFirst) { if (isFirst) {
this.vm.viewState = DSViewState.busy; this.vm!.viewState = DSViewState.busy;
} }
_priceRepository _priceRepository
.getSellingRecommends( .getSellingRecommends(
keywords: _pageParam['keywords'], keywords: _pageParam!['keywords'],
excludeId: _pageParam['excludeId'], excludeId: _pageParam!['excludeId'],
page: page, page: page,
pagesize: pagesize, pagesize: pagesize,
) )
...@@ -99,37 +99,37 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> { ...@@ -99,37 +99,37 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
List<ProductItemEntity> productEntitys = value.data; List<ProductItemEntity> productEntitys = value.data;
productEntitys.forEach((ele) { productEntitys.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime); ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = _getPlatformName(int.parse(ele.platform)); ele.platform = _getPlatformName(int.parse(ele.platform!));
}); });
if (isLoad) { if (isLoad) {
if (this.vm.productEntitys == null) { if (this.vm!.productEntitys == null) {
this.vm.productEntitys = List<ProductItemEntity>.empty(growable: true); this.vm!.productEntitys = List<ProductItemEntity>.empty(growable: true);
} }
this.vm.productEntitys.addAll(productEntitys); this.vm!.productEntitys!.addAll(productEntitys);
} else { } else {
this.vm.productEntitys = productEntitys; this.vm!.productEntitys = productEntitys;
if (this.vm.productEntitys.isEmpty) { if (this.vm!.productEntitys!.isEmpty) {
this.vm.viewState = DSViewState.empty; this.vm!.viewState = DSViewState.empty;
} else { } else {
this.vm.viewState = DSViewState.idle; this.vm!.viewState = DSViewState.idle;
} }
} }
} }
if (isLoad) { if (isLoad) {
_discountDelegate.onLoadComplete(isLoading: true); _discountDelegate!.onLoadComplete(isLoading: true);
} else if (isRefresh) { } else if (isRefresh) {
_discountDelegate.onLoadComplete(isLoading: false); _discountDelegate!.onLoadComplete(isLoading: false);
} }
}).catchError((error) { }).catchError((error) {
this.vm.viewState = DSViewState.error; this.vm!.viewState = DSViewState.error;
if (isLoad) { if (isLoad) {
_discountDelegate.onloadFailed(isLoading: true); _discountDelegate!.onloadFailed(isLoading: true);
} else if (isRefresh) { } else if (isRefresh) {
_discountDelegate.onloadFailed(isLoading: false); _discountDelegate!.onloadFailed(isLoading: false);
} }
}).whenComplete(() { }).whenComplete(() {
this.vm.notifyListener(); this.vm!.notifyListener();
}); });
} }
...@@ -138,16 +138,16 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> { ...@@ -138,16 +138,16 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
/// [platform] 平台id /// [platform] 平台id
/// ///
String _getPlatformName(int platform) { String _getPlatformName(int platform) {
if (_platformIconMap != null && _platformIconMap[platform] is Map) { if (_platformIconMap != null && _platformIconMap![platform] is Map) {
Map<String, dynamic> platformMap = Map<String, dynamic> platformMap =
Map<String, dynamic>.from(_platformIconMap[platform]); Map<String, dynamic>.from(_platformIconMap![platform]);
return platformMap['name'] ?? ''; return platformMap['name'] ?? '';
} }
return ''; return '';
} }
@override @override
PriceDiscountVo get getVo => this.vm; PriceDiscountVo? get getVo => this.vm;
} }
/// ///
...@@ -162,5 +162,5 @@ abstract class IPriceDiscountDelegate { ...@@ -162,5 +162,5 @@ abstract class IPriceDiscountDelegate {
/// ///
/// 数据加载失败 /// 数据加载失败
/// ///
void onloadFailed({bool isLoading = true, String msg}); void onloadFailed({bool isLoading = true, String? msg});
} }
...@@ -9,16 +9,16 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> { ...@@ -9,16 +9,16 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> {
/// ///
/// 代理设置 /// 代理设置
/// ///
IPriceAction({IPriceActionDelegate delegate, bool isGrid}); IPriceAction({IPriceActionDelegate? delegate, bool? isGrid});
/// ///
/// 设置分类参数 /// 设置分类参数
/// ///
void setPriceCategory( void setPriceCategory(
{List<dynamic> sellingTabList, {List<dynamic>? sellingTabList,
List<dynamic> priceCategory, List<dynamic>? priceCategory,
Map<int, dynamic> platformIconMap, Map<int, dynamic>? platformIconMap,
String keywords}); String? keywords});
/// ///
/// 获取分类Tab /// 获取分类Tab
...@@ -48,7 +48,7 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> { ...@@ -48,7 +48,7 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> {
/// ///
/// 查询筛选条件 /// 查询筛选条件
/// ///
void qryProductListEvent({String keywords, int page}); void qryProductListEvent({String? keywords, int? page});
/// ///
/// 刷新 /// 刷新
...@@ -63,10 +63,10 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> { ...@@ -63,10 +63,10 @@ abstract class IPriceAction<PriceVo> extends IDSAction<PriceVo> {
class PriceAction extends IPriceAction<PriceVo> { class PriceAction extends IPriceAction<PriceVo> {
PriceRepository _repository = PriceRepository.get(); PriceRepository _repository = PriceRepository.get();
Map<int, dynamic> platformIconMap; Map<int, dynamic>? platformIconMap;
String keywords; String? keywords;
bool isGrid = false; bool? isGrid = false;
IPriceActionDelegate delegate; IPriceActionDelegate? delegate;
PriceAction({this.delegate, this.isGrid}) : super(delegate: delegate); PriceAction({this.delegate, this.isGrid}) : super(delegate: delegate);
@override @override
...@@ -82,14 +82,14 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -82,14 +82,14 @@ class PriceAction extends IPriceAction<PriceVo> {
} }
@override @override
List<dynamic> get sellingTabs => this.vm.sellingTabs ?? []; List<dynamic> get sellingTabs => this.vm!.sellingTabs ?? [];
@override @override
void setPriceCategory( void setPriceCategory(
{List<dynamic> sellingTabList, {List<dynamic>? sellingTabList,
List<dynamic> priceCategory, List<dynamic>? priceCategory,
Map<int, dynamic> platformIconMap, Map<int, dynamic>? platformIconMap,
String keywords}) { String? keywords}) {
this.platformIconMap = platformIconMap; this.platformIconMap = platformIconMap;
this.page = 1; this.page = 1;
if (keywords != null && keywords.isNotEmpty) { if (keywords != null && keywords.isNotEmpty) {
...@@ -99,16 +99,16 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -99,16 +99,16 @@ class PriceAction extends IPriceAction<PriceVo> {
if (this.vm == null) { if (this.vm == null) {
this.vm = PriceVo(); this.vm = PriceVo();
} }
if (this.vm.tabListVo == null) { if (this.vm!.tabListVo == null) {
this.vm.tabListVo = TabListVo(); this.vm!.tabListVo = TabListVo();
} }
this.vm.sellingTabs = sellingTabList; this.vm!.sellingTabs = sellingTabList;
dynamic data = this dynamic data = this
.vm .vm!
.sellingTabs .sellingTabs
?.singleWhere((ele) => ele['is_default'] == '1', orElse: () => null); ?.singleWhere((ele) => ele['is_default'] == '1', orElse: () => null);
if (data != null && data is Map<String, dynamic>) { if (data != null && data is Map<String, dynamic>) {
this.vm.tabListVo.sellTab = Map<String, dynamic>.from(data); this.vm!.tabListVo!.sellTab = Map<String, dynamic>.from(data);
} }
if (priceCategory != null) { if (priceCategory != null) {
List<TabVo> tabList = List<TabVo>.empty(growable: true); List<TabVo> tabList = List<TabVo>.empty(growable: true);
...@@ -117,22 +117,22 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -117,22 +117,22 @@ class PriceAction extends IPriceAction<PriceVo> {
tabList.add(TabVo.fromJson( tabList.add(TabVo.fromJson(
'${categoryMap['type']}', Map<String, dynamic>.from(ele))); '${categoryMap['type']}', Map<String, dynamic>.from(ele)));
}); });
TabListVo tabListVo = this.vm.tabListVo; TabListVo tabListVo = this.vm!.tabListVo!;
tabListVo.tabList = tabList; tabListVo.tabList = tabList;
this.vm.tabListVo = tabListVo; this.vm!.tabListVo = tabListVo;
} }
TabListVo tabListVo = this.vm.tabListVo; TabListVo tabListVo = this.vm!.tabListVo!;
String categoryId; String? categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab['id'] != null) { if (tabListVo.sellTab != null && tabListVo.sellTab!['id'] != null) {
categoryId = "${tabListVo.sellTab['id']}"; categoryId = "${tabListVo.sellTab!['id']}";
} }
_qryProductList(keywords: keywords, categoryId: categoryId); _qryProductList(keywords: keywords, categoryId: categoryId);
} }
@override @override
TabListVo getTabListVo() { TabListVo getTabListVo() {
return this.vm.tabListVo ?? TabListVo(); return this.vm!.tabListVo ?? TabListVo();
} }
@override @override
...@@ -145,12 +145,12 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -145,12 +145,12 @@ class PriceAction extends IPriceAction<PriceVo> {
/// ///
@override @override
void resetProductList() async { void resetProductList() async {
for (TabVo item in this.vm.tabListVo?.tabList ?? []) { for (TabVo item in this.vm!.tabListVo?.tabList ?? []) {
item.selected = null; item.selected = null;
item.open = false; item.open = false;
} }
this.vm.tabListVo?.sellTab = null; this.vm!.tabListVo?.sellTab = null;
this.vm.tabListVo?.notifyListener(true); this.vm!.tabListVo?.notifyListener(true);
_qryProductList(keywords: this.keywords); _qryProductList(keywords: this.keywords);
} }
...@@ -158,12 +158,12 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -158,12 +158,12 @@ class PriceAction extends IPriceAction<PriceVo> {
/// 过滤筛选条件 /// 过滤筛选条件
/// ///
@override @override
void qryProductListEvent({String keywords, int page = 1}) async { void qryProductListEvent({String? keywords, int? page = 1}) async {
if (keywords != null) { if (keywords != null) {
this.keywords = keywords; this.keywords = keywords;
} }
List<dynamic> filters; List<dynamic>? filters;
this.vm.tabListVo?.tabList?.forEach((ele) { this.vm!.tabListVo?.tabList.forEach((ele) {
if (filters == null) { if (filters == null) {
filters = List<dynamic>.empty(growable: true); filters = List<dynamic>.empty(growable: true);
} }
...@@ -172,39 +172,39 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -172,39 +172,39 @@ class PriceAction extends IPriceAction<PriceVo> {
if (ele.keyName == 'category') { if (ele.keyName == 'category') {
data = { data = {
'key_name': ele.keyName, 'key_name': ele.keyName,
'key_value': '${ele.selected['id']}' 'key_value': '${ele.selected!['id']}'
}; };
} else if (ele.keyName == 'price_section') { } else if (ele.keyName == 'price_section') {
data = { data = {
'key_name': ele.keyName, 'key_name': ele.keyName,
'key_value': ele.selected['price_section'] 'key_value': ele.selected!['price_section']
}; };
} else { } else {
data = { data = {
'key_name': ele.keyName, 'key_name': ele.keyName,
'key_value': '${ele.selected['type']}' 'key_value': '${ele.selected!['type']}'
}; };
} }
if (data != null && data.isNotEmpty) { if (data.isNotEmpty) {
filters.add(data); filters!.add(data);
} }
} }
}); });
TabListVo tabListVo = this.vm.tabListVo; TabListVo tabListVo = this.vm!.tabListVo!;
String categoryId; String? categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab['id'] != null) { if (tabListVo.sellTab != null && tabListVo.sellTab!['id'] != null) {
categoryId = "${tabListVo.sellTab['id']}"; categoryId = "${tabListVo.sellTab!['id']}";
} }
_qryProductList( _qryProductList(
keywords: this.keywords, keywords: this.keywords,
filters: filters, filters: filters,
page: page, page: page!,
categoryId: categoryId); categoryId: categoryId);
} }
@override @override
void closeTab() { void closeTab() {
TabListVo tabListVo = this.vm.tabListVo; TabListVo tabListVo = this.vm!.tabListVo!;
tabListVo.tabList.forEach((ele) { tabListVo.tabList.forEach((ele) {
ele.open = false; ele.open = false;
}); });
...@@ -212,9 +212,9 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -212,9 +212,9 @@ class PriceAction extends IPriceAction<PriceVo> {
} }
String getPlatformName(int platform) { String getPlatformName(int platform) {
if (platformIconMap != null && platformIconMap[platform] is Map) { if (platformIconMap != null && platformIconMap![platform] is Map) {
Map<String, dynamic> platformMap = Map<String, dynamic> platformMap =
Map<String, dynamic>.from(platformIconMap[platform]); Map<String, dynamic>.from(platformIconMap![platform]);
return platformMap['name'] ?? ''; return platformMap['name'] ?? '';
} }
return ''; return '';
...@@ -223,10 +223,10 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -223,10 +223,10 @@ class PriceAction extends IPriceAction<PriceVo> {
void _qryProductList( void _qryProductList(
{int page = 1, {int page = 1,
int pagesize = 10, int pagesize = 10,
String keywords, String? keywords,
String categoryId, String? categoryId,
List<dynamic> filters}) async { List<dynamic>? filters}) async {
this.page = page ?? 1; this.page = page;
await _repository await _repository
.qryProductList( .qryProductList(
page: page, page: page,
...@@ -242,8 +242,8 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -242,8 +242,8 @@ class PriceAction extends IPriceAction<PriceVo> {
if (value.isSuccess) { if (value.isSuccess) {
productList = value.data; productList = value.data;
productList.forEach((ele) { productList.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime); ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = getPlatformName(int.parse(ele.platform)); ele.platform = getPlatformName(int.parse(ele.platform!));
}); });
} }
this.vm?.productListVo?.productList = productList; this.vm?.productListVo?.productList = productList;
...@@ -252,11 +252,10 @@ class PriceAction extends IPriceAction<PriceVo> { ...@@ -252,11 +252,10 @@ class PriceAction extends IPriceAction<PriceVo> {
if (value.isSuccess) { if (value.isSuccess) {
productList = value.data; productList = value.data;
productList.forEach((ele) { productList.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime); ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = getPlatformName(int.parse(ele.platform)); ele.platform = getPlatformName(int.parse(ele.platform!));
}); });
this.vm?.productListVo?.productList.addAll(productList);
this.vm?.productListVo?.productList?.addAll(productList);
} }
} }
delegate?.onLoadComplete(); delegate?.onLoadComplete();
...@@ -293,5 +292,5 @@ abstract class IPriceActionDelegate { ...@@ -293,5 +292,5 @@ abstract class IPriceActionDelegate {
/// ///
/// 数据加载失败 /// 数据加载失败
/// ///
void onloadFailed({String msg}); void onloadFailed({String? msg});
} }
...@@ -2,50 +2,50 @@ import 'package:price_module/framework/model/ds_model.dart'; ...@@ -2,50 +2,50 @@ import 'package:price_module/framework/model/ds_model.dart';
import 'package:xiaoxiong_repository/entity/product_item_entity.dart'; import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
class PriceDetailsVo extends IDSModel { class PriceDetailsVo extends IDSModel {
String productId; String? productId;
List<String> itemPic; List<String?>? itemPic;
String itemTitle; String? itemTitle;
String subTitle; String? subTitle;
String description; String? description;
String status; String? status;
//商品的ItemId //商品的ItemId
String itemId; String? itemId;
//平台Id //平台Id
String platform; String? platform;
//平台名称 //平台名称
String platformText; String? platformText;
//喜欢次数 //喜欢次数
String likeTimes; String? likeTimes;
//收藏次数 //收藏次数
String collegeTimes; String? collegeTimes;
//是否喜欢和收藏 //是否喜欢和收藏
bool isLike = false; bool isLike = false;
bool isFavorites = false; bool isFavorites = false;
//Button按钮的文字 //Button按钮的文字
String buttonText; String? buttonText;
String price; String? price;
String endPrice; String? endPrice;
//发布时间 //发布时间
String releaseTime; String? releaseTime;
String checkText; String? checkText;
//分享文字和分享URL //分享文字和分享URL
String shareUrl; String? shareUrl;
String shareMessage; String? shareMessage;
//优惠卷 //优惠卷
List<Coupon> coupons = []; List<Coupon> coupons = [];
//举报 //举报
List<ReportModel> reports = []; List<ReportModel>? reports = [];
//优惠卷过期描述 //优惠卷过期描述
String couponText; String? couponText;
String isOverdue; String? isOverdue;
String shopTitle; String? shopTitle;
String rebate; String? rebate;
List<dynamic> collectOrders; List<dynamic>? collectOrders;
Map<String, dynamic> newItemInfo; Map<String, dynamic>? newItemInfo;
//商品推荐相关信息 //商品推荐相关信息
List<ProductItemEntity> productEntitys; List<ProductItemEntity>? productEntitys;
PriceDetailsVo({ PriceDetailsVo({
this.productId, this.productId,
...@@ -79,15 +79,15 @@ class PriceDetailsVo extends IDSModel { ...@@ -79,15 +79,15 @@ class PriceDetailsVo extends IDSModel {
} }
class Coupon { class Coupon {
String url; String? url;
String name; String? name;
String status; String? status;
Coupon({this.url, this.name, this.status}); Coupon({this.url, this.name, this.status});
} }
class ReportModel { class ReportModel {
String value; String? value;
String text; String? text;
List<ReportModel> sub = []; List<ReportModel>? sub = [];
ReportModel({this.value, this.text, this.sub}); ReportModel({this.value, this.text, this.sub});
} }
...@@ -7,6 +7,6 @@ class PriceDiscountVo extends IDSModel{ ...@@ -7,6 +7,6 @@ class PriceDiscountVo extends IDSModel{
/// ///
/// 好价商品列表 /// 好价商品列表
/// ///
List<ProductItemEntity> productEntitys; List<ProductItemEntity>? productEntitys;
} }
\ No newline at end of file
...@@ -3,12 +3,12 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart'; ...@@ -3,12 +3,12 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
class PriceVo extends IDSModel { class PriceVo extends IDSModel {
// 商品列表 // 商品列表
ProductListVo productListVo; ProductListVo? productListVo;
//筛选Tab //筛选Tab
TabListVo tabListVo; TabListVo? tabListVo;
// 快捷分类列表 // 快捷分类列表
List<dynamic> sellingTabs; List<dynamic>? sellingTabs;
PriceVo({this.productListVo, this.tabListVo, this.sellingTabs}); PriceVo({this.productListVo, this.tabListVo, this.sellingTabs});
} }
...@@ -17,19 +17,19 @@ class TabListVo extends IDSModel { ...@@ -17,19 +17,19 @@ class TabListVo extends IDSModel {
//分类 //分类
List<TabVo> tabList = []; List<TabVo> tabList = [];
//快捷分类 //快捷分类
Map<String, dynamic> sellTab; Map<String, dynamic>? sellTab;
TabListVo({this.tabList = const [], this.sellTab}); TabListVo({this.tabList = const [], this.sellTab});
} }
class TabVo extends IDSModel { class TabVo extends IDSModel {
String type; String? type;
String text; String? text;
String keyName; String? keyName;
bool open = false; bool open = false;
Map<String, dynamic> selected; Map<String?, dynamic>? selected;
List<dynamic> structure; List<dynamic>? structure;
TabVo({this.type, this.text, this.keyName, this.structure, this.selected}); TabVo({this.type, this.text, this.keyName, this.structure, this.selected});
...@@ -45,7 +45,7 @@ class TabVo extends IDSModel { ...@@ -45,7 +45,7 @@ class TabVo extends IDSModel {
} }
class ProductListVo extends IDSModel { class ProductListVo extends IDSModel {
bool isGrid = false; bool? isGrid = false;
List<ProductItemEntity> productList = []; List<ProductItemEntity> productList = [];
ProductListVo({this.productList = const [], this.isGrid = false}); ProductListVo({this.productList = const [], this.isGrid = false});
} }
import 'package:flutter/material.dart';
import 'package:price_module/framework/model/ds_model.dart'; import 'package:price_module/framework/model/ds_model.dart';
import 'package:price_module/page/model/details/index.dart'; import 'package:price_module/page/model/details/index.dart';
import 'package:price_module/utils/time_utils.dart'; import 'package:price_module/utils/time_utils.dart';
...@@ -15,15 +14,15 @@ class PriceDetailsService { ...@@ -15,15 +14,15 @@ class PriceDetailsService {
/// 查询商品详情 /// 查询商品详情
/// [productId] 查询的商品Id /// [productId] 查询的商品Id
/// ///
Future<PriceDetailsVo> qryProductDetails({@required String productId}) async { Future<PriceDetailsVo> qryProductDetails({required String productId}) async {
return await _priceRepository return await _priceRepository
.qryProductDetails(id: productId) .qryProductDetails(id: productId)
.asStream() .asStream()
.map((event) { .map((event) {
PriceDetailsVo detailsVo; PriceDetailsVo? detailsVo;
if (event.isSuccess) { if (event.isSuccess) {
detailsVo = PriceDetailsVo(); detailsVo = PriceDetailsVo();
ProductDetailsEntity entity = event.data; ProductDetailsEntity entity = event.data!;
detailsVo.viewState = DSViewState.idle; detailsVo.viewState = DSViewState.idle;
detailsVo.likeTimes = entity.likeTimes; detailsVo.likeTimes = entity.likeTimes;
detailsVo.collegeTimes = entity.collegeTimes; detailsVo.collegeTimes = entity.collegeTimes;
...@@ -40,18 +39,16 @@ class PriceDetailsService { ...@@ -40,18 +39,16 @@ class PriceDetailsService {
detailsVo.isFavorites = entity.isCollect == '1'; detailsVo.isFavorites = entity.isCollect == '1';
detailsVo.shareMessage = entity.shareMessage ?? ''; detailsVo.shareMessage = entity.shareMessage ?? '';
detailsVo.shareUrl = entity.shareUrl ?? ''; detailsVo.shareUrl = entity.shareUrl ?? '';
if (entity.releaseTime != null && entity.releaseTime.length > 0) { if (entity.releaseTime != null && entity.releaseTime!.length > 0) {
detailsVo.releaseTime = detailsVo.releaseTime =
TimeUtils.formatTime(timestamp: entity.releaseTime); TimeUtils.formatTime(timestamp: entity.releaseTime!);
} }
detailsVo.checkText = entity.checkText ?? ''; detailsVo.checkText = entity.checkText ?? '';
detailsVo.endPrice = entity.endPrice; detailsVo.endPrice = entity.endPrice;
detailsVo.price = entity.price; detailsVo.price = entity.price;
detailsVo.coupons = detailsVo.coupons = List.generate(entity.couponInfos?.length??0, (index) {
List.generate(entity.couponInfos?.length, (index) { CouponInfo info = entity.couponInfos![index];
CouponInfo info = entity.couponInfos[index]; return Coupon(name: info.couponName, url: info.url, status: info.status);
return Coupon(
name: info.couponName, url: info.url, status: info.status);
}); });
detailsVo.isOverdue = entity.isOverdue; detailsVo.isOverdue = entity.isOverdue;
detailsVo.shopTitle = entity.shopTitle; detailsVo.shopTitle = entity.shopTitle;
...@@ -75,8 +72,8 @@ class PriceDetailsService { ...@@ -75,8 +72,8 @@ class PriceDetailsService {
/// [pagesize] 当前页显示的大小 /// [pagesize] 当前页显示的大小
/// ///
Future<DSResponseList<ProductItemEntity>> getSellingRecommends({ Future<DSResponseList<ProductItemEntity>> getSellingRecommends({
String keywords, String? keywords,
String excludeId, String? excludeId,
int page = 1, int page = 1,
int pagesize = 10, int pagesize = 10,
}) async { }) async {
...@@ -94,7 +91,7 @@ class PriceDetailsService { ...@@ -94,7 +91,7 @@ class PriceDetailsService {
/// [report_type] 举报的商品类型 /// [report_type] 举报的商品类型
/// ///
Future<dynamic> report( Future<dynamic> report(
{@required String id, @required String reportType}) async { {required String id, required String reportType}) async {
return await _priceRepository return await _priceRepository
.report(id: id, reportType: reportType) .report(id: id, reportType: reportType)
.asStream() .asStream()
...@@ -111,8 +108,8 @@ class PriceDetailsService { ...@@ -111,8 +108,8 @@ class PriceDetailsService {
/// [platform] 平台 /// [platform] 平台
/// ///
Future<dynamic> userLike( Future<dynamic> userLike(
{@required String markId, {required String markId,
@required String platform, required String platform,
String type = '2', String type = '2',
String status = '1'}) async { String status = '1'}) async {
return await _priceRepository return await _priceRepository
...@@ -128,8 +125,8 @@ class PriceDetailsService { ...@@ -128,8 +125,8 @@ class PriceDetailsService {
/// 用户收藏 /// 用户收藏
/// ///
Future<dynamic> userCollect( Future<dynamic> userCollect(
{@required String itemId, {required String itemId,
@required String platform, required String platform,
String type = '2', String type = '2',
String status = '1'}) async { String status = '1'}) async {
return await _priceRepository return await _priceRepository
...@@ -148,8 +145,8 @@ class PriceDetailsService { ...@@ -148,8 +145,8 @@ class PriceDetailsService {
/// [type] 转链类型 好价传6 默认为5 /// [type] 转链类型 好价传6 默认为5
/// ///
Future<DSResponseObject<TurnChainEntity>> turnChainForItemId( Future<DSResponseObject<TurnChainEntity>> turnChainForItemId(
{@required String itemId, {required String itemId,
@required String platform, required String platform,
String type = '6'}) async { String type = '6'}) async {
return await _priceRepository return await _priceRepository
.turnChainForItemId(itemId: itemId, platform: platform, type: type) .turnChainForItemId(itemId: itemId, platform: platform, type: type)
......
...@@ -16,24 +16,24 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart'; ...@@ -16,24 +16,24 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
class PriceDetailsPage extends StatefulWidget { class PriceDetailsPage extends StatefulWidget {
final Map<String, dynamic> pageParam; final Map<String, dynamic> pageParam;
final Function(Map<String, dynamic>) onCallbackParams; final Function(Map<String, dynamic>)? onCallbackParams;
final Function(String, String) onH5Callback; final Function(String?, String?)? onH5Callback;
final Function(String) onCopyLink; final Function(String?) onCopyLink;
final Widget Function( final Widget Function(
BuildContext context, BuildContext context,
PriceDetailsVo detailsVo, PriceDetailsVo detailsVo,
GlobalKey convertKey, GlobalKey convertKey,
) onShareWidget; )? onShareWidget;
final Function(BuildContext context, final Function(BuildContext context,
{String path, String type, @required GlobalKey convertKey}) onShare; {String? path, String? type, required GlobalKey convertKey}) onShare;
const PriceDetailsPage( const PriceDetailsPage(
{Key key, {Key? key,
@required this.pageParam, required this.pageParam,
this.onShareWidget, this.onShareWidget,
this.onCallbackParams, this.onCallbackParams,
this.onH5Callback, this.onH5Callback,
@required this.onCopyLink, required this.onCopyLink,
@required this.onShare}) required this.onShare})
: super(key: key); : super(key: key);
@override @override
...@@ -45,16 +45,16 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -45,16 +45,16 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
//分享图片key //分享图片key
GlobalKey _convertKey = GlobalKey(); GlobalKey _convertKey = GlobalKey();
IPriceDetailsAction<PriceDetailsVo> _detailsAction; IPriceDetailsAction<PriceDetailsVo>? _detailsAction;
ScrollController scrollController = ScrollController(); ScrollController scrollController = ScrollController();
bool silverCollapsed = false; bool silverCollapsed = false;
ValueNotifier<int> _appBarListenable = ValueNotifier<int>(0); ValueNotifier<int> _appBarListenable = ValueNotifier<int>(0);
AnimationController likeAnimationController; AnimationController? likeAnimationController;
AnimationController favoritesAnimationController; AnimationController? favoritesAnimationController;
bool isAudituser; bool? isAudituser;
@override @override
void initState() { void initState() {
likeImages.add('assets/images/like/ic_like_unselected.png'); likeImages.add('assets/images/like/ic_like_unselected.png');
...@@ -69,22 +69,22 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -69,22 +69,22 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
AnimationController(vsync: this, duration: Duration(milliseconds: 400)); AnimationController(vsync: this, duration: Duration(milliseconds: 400));
Animation<double> likeAnimation = Animation<double> likeAnimation =
Tween<double>(begin: 1, end: likeImages.length.toDouble() - 1) Tween<double>(begin: 1, end: likeImages.length.toDouble() - 1)
.animate(likeAnimationController); .animate(likeAnimationController!);
likeAnimationController.addListener(() { likeAnimationController!.addListener(() {
likeValueNotifier.value = likeAnimation.value.toInt(); likeValueNotifier.value = likeAnimation.value.toInt();
}); });
favoritesAnimationController = favoritesAnimationController =
AnimationController(vsync: this, duration: Duration(milliseconds: 400)); AnimationController(vsync: this, duration: Duration(milliseconds: 400));
Animation<double> favoritesAnimation = Animation<double> favoritesAnimation =
Tween<double>(begin: 1, end: favoritesImages.length.toDouble() - 1) Tween<double>(begin: 1, end: favoritesImages.length.toDouble() - 1)
.animate(favoritesAnimationController); .animate(favoritesAnimationController!);
favoritesAnimationController.addListener(() { favoritesAnimationController!.addListener(() {
favoritesValueNotifier.value = favoritesAnimation.value.toInt(); favoritesValueNotifier.value = favoritesAnimation.value.toInt();
}); });
super.initState(); super.initState();
try { try {
if (widget.pageParam["isAudituser"] != null) { if (widget.pageParam["isAudituser"] != null) {
isAudituser = widget.pageParam["isAudituser"] as bool; isAudituser = widget.pageParam["isAudituser"] as bool?;
} }
} catch (e) {} } catch (e) {}
_detailsAction = _detailsAction =
...@@ -108,12 +108,12 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -108,12 +108,12 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
/// 好价详情 /// 好价详情
/// ///
Widget _buildBody(BuildContext context, Widget _buildBody(BuildContext context,
{ScrollController controller, @required PriceDetailsVo detailsVo}) { {ScrollController? controller, required PriceDetailsVo detailsVo}) {
return NotificationListener( return NotificationListener(
child: Stack(children: [ child: Stack(children: [
detailsVo.viewState == DSViewState.busy detailsVo.viewState == DSViewState.busy
? Container() ? Container()
: widget.onShareWidget(context, detailsVo, _convertKey), : widget.onShareWidget!(context, detailsVo, _convertKey),
Container( Container(
color: Colors.white, color: Colors.white,
child: ListView( child: ListView(
...@@ -124,7 +124,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -124,7 +124,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
//顶部的滚动栏 //顶部的滚动栏
buildSwiperWidget(images: detailsVo?.itemPic ?? []), buildSwiperWidget(images: detailsVo.itemPic ?? []),
SizedBox( SizedBox(
height: 16, height: 16,
...@@ -132,7 +132,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -132,7 +132,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
Container( Container(
child: LayoutBuilder(builder: child: LayoutBuilder(builder:
(BuildContext context, BoxConstraints constraints) { (BuildContext context, BoxConstraints constraints) {
String value = detailsVo.itemTitle; String value = detailsVo.itemTitle!;
return Text( return Text(
value, value,
style: TextStyle( style: TextStyle(
...@@ -156,10 +156,10 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -156,10 +156,10 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
buildProductNewlastWidget( buildProductNewlastWidget(
newInfo: detailsVo.newItemInfo, newInfo: detailsVo.newItemInfo,
goBuy: () { goBuy: () {
_detailsAction.goToBuyEvent().then((value) { _detailsAction!.goToBuyEvent().then((value) {
if (value != null && if (value != null &&
widget.onH5Callback != null) { widget.onH5Callback != null) {
widget.onH5Callback( widget.onH5Callback!(
value.appLink, value.platform); value.appLink, value.platform);
} }
}).catchError((error) { }).catchError((error) {
...@@ -174,7 +174,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -174,7 +174,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
if (coupon['status'] == '1' && if (coupon['status'] == '1' &&
coupon['url'] != null) { coupon['url'] != null) {
if (widget.onH5Callback != null) { if (widget.onH5Callback != null) {
widget.onH5Callback( widget.onH5Callback!(
coupon['url'], detailsVo.platform); coupon['url'], detailsVo.platform);
} }
} }
...@@ -186,24 +186,24 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -186,24 +186,24 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
onCouponTap: (Coupon coupon) { onCouponTap: (Coupon coupon) {
if (coupon.status == '1' && coupon.url != null) { if (coupon.status == '1' && coupon.url != null) {
if (widget.onH5Callback != null) { if (widget.onH5Callback != null) {
widget.onH5Callback( widget.onH5Callback!(
coupon.url, detailsVo.platform); coupon.url, detailsVo.platform);
} }
} }
}, },
onPurchase: (data) { onPurchase: (data) {
if (data == null || data['item_id'] == null) { if (data['item_id'] == null) {
return; return;
} }
String itemId = data['item_id']; String? itemId = data['item_id'];
String platform = data['platform']; String? platform = data['platform'];
_detailsAction _detailsAction!
.goToBuyItemId(itemId: itemId, platform: platform) .goToBuyItemId(itemId: itemId, platform: platform)
.then( .then(
(value) { (value) {
if (value != null && if (value != null &&
widget.onH5Callback != null) { widget.onH5Callback != null) {
widget.onH5Callback( widget.onH5Callback!(
value.appLink, value.platform); value.appLink, value.platform);
} }
}, },
...@@ -219,7 +219,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -219,7 +219,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
//商品详情 //商品详情
Container( Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
child: Html(data: detailsVo?.description ?? '')), child: Html(data: detailsVo.description ?? '')),
//举报和提示 //举报和提示
detailsVo.viewState == DSViewState.busy detailsVo.viewState == DSViewState.busy
? Container( ? Container(
...@@ -257,7 +257,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -257,7 +257,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
RoutePath.PRICE_DISCOUNT_PAGE.path(), RoutePath.PRICE_DISCOUNT_PAGE.path(),
arguments: { arguments: {
'isAudituser': isAudituser, 'isAudituser': isAudituser,
'sellReportList': _detailsAction.sellReportList, 'sellReportList': _detailsAction!.sellReportList,
'excludeId': detailsVo.productId, 'excludeId': detailsVo.productId,
'keywords': detailsVo.itemTitle, 'keywords': detailsVo.itemTitle,
}, },
...@@ -266,7 +266,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -266,7 +266,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
onItemTap: (ProductItemEntity entity, int index) async { onItemTap: (ProductItemEntity entity, int index) async {
Map<String, dynamic> params = { Map<String, dynamic> params = {
'isAudituser': isAudituser, 'isAudituser': isAudituser,
'sellReportList': _detailsAction.sellReportList, 'sellReportList': _detailsAction!.sellReportList,
'productId': entity.id, 'productId': entity.id,
'src': entity.itemPic, 'src': entity.itemPic,
'title': entity.itemTitle, 'title': entity.itemTitle,
...@@ -284,7 +284,8 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -284,7 +284,8 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
audituser: isAudituser, audituser: isAudituser,
detailsVo: detailsVo, detailsVo: detailsVo,
listenable: _appBarListenable, listenable: _appBarListenable,
onSharePressed: onSharePressed), onSharePressed:(PriceDetailsVo? detailsVo)=>onSharePressed(detailsVo: detailsVo)
),
]), ]),
onNotification: (ScrollNotification notification) { onNotification: (ScrollNotification notification) {
if (notification.metrics.outOfRange == true || if (notification.metrics.outOfRange == true ||
...@@ -307,7 +308,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -307,7 +308,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
); );
} }
void onSharePressed({@required PriceDetailsVo detailsVo}) { void onSharePressed({required PriceDetailsVo? detailsVo}) {
List<Map<String, dynamic>> items = [ List<Map<String, dynamic>> items = [
{ {
'key': 'friend', 'key': 'friend',
...@@ -331,14 +332,14 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -331,14 +332,14 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
} }
]; ];
showShareModalBottom<String>(context, items: items, extras: { showShareModalBottom<String>(context, items: items, extras: {
'product_id': detailsVo.productId, 'product_id': detailsVo!.productId,
'platform': detailsVo.platform, 'platform': detailsVo.platform,
'item_id': detailsVo.itemId, 'item_id': detailsVo.itemId,
}).then((value) async { }).then((value) async {
if (value == 'product') { if (value == 'product') {
if (widget.onCallbackParams != null) { if (widget.onCallbackParams != null) {
if (detailsVo.platform == '10' || detailsVo.platform == '1') { if (detailsVo.platform == '10' || detailsVo.platform == '1') {
widget.onCallbackParams( widget.onCallbackParams!(
{'itemId': detailsVo.itemId, 'platform': detailsVo.platform}); {'itemId': detailsVo.itemId, 'platform': detailsVo.platform});
} else { } else {
_showShareQRModalBottom(context: context, detailsVo: detailsVo); _showShareQRModalBottom(context: context, detailsVo: detailsVo);
...@@ -353,14 +354,14 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -353,14 +354,14 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
scene: value == 'wechat' scene: value == 'wechat'
? WeChatScene.SESSION ? WeChatScene.SESSION
: WeChatScene.TIMELINE, : WeChatScene.TIMELINE,
thumbnail: WeChatImage.network(detailsVo.itemPic[0])); thumbnail: WeChatImage.network(detailsVo.itemPic![0]!));
shareToWeChat(model).then((value) {}); shareToWeChat(model).then((value) {});
} catch (e) { } catch (e) {
print("------------------------------> value:$e"); print("------------------------------> value:$e");
} }
} else if (value == 'copyLink') { } else if (value == 'copyLink') {
if (detailsVo.shareMessage != null && if (detailsVo.shareMessage != null &&
detailsVo.shareMessage.isNotEmpty) { detailsVo.shareMessage!.isNotEmpty) {
widget.onCopyLink(detailsVo.shareMessage); widget.onCopyLink(detailsVo.shareMessage);
FlutterNativeToast.showToast('复制成功'); FlutterNativeToast.showToast('复制成功');
} }
...@@ -374,7 +375,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -374,7 +375,7 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
/// detailsVo 商品详情 /// detailsVo 商品详情
/// ///
void _showShareQRModalBottom( void _showShareQRModalBottom(
{BuildContext context, PriceDetailsVo detailsVo}) { {required BuildContext context, required PriceDetailsVo detailsVo}) {
List<Map<String, dynamic>> items = [ List<Map<String, dynamic>> items = [
{ {
'key': 'photo_save', 'key': 'photo_save',
...@@ -408,13 +409,13 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -408,13 +409,13 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
/// [reports] 举报弹窗的信息 /// [reports] 举报弹窗的信息
/// ///
void _showReceiveModalBottom(BuildContext context, void _showReceiveModalBottom(BuildContext context,
{@required List<ReportModel> reports}) { {required List<ReportModel> reports}) {
showReceiveModalBottom<ReportModel>(context, items: reports).then((value) { showReceiveModalBottom<ReportModel>(context, items: reports).then((value) {
if (value != null) { if (value != null) {
if (value.sub != null && value.sub.length > 0) { if (value.sub != null && value.sub!.length > 0) {
_showReceiveModalBottom(context, reports: value.sub); _showReceiveModalBottom(context, reports: value.sub!);
} else { } else {
_detailsAction.report(reportType: value.value); _detailsAction!.report(reportType: value.value);
} }
} }
}); });
...@@ -424,12 +425,12 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -424,12 +425,12 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DSProviderWidget<PriceDetailsVo, return DSProviderWidget<PriceDetailsVo,
IPriceDetailsAction<PriceDetailsVo>>( IPriceDetailsAction<PriceDetailsVo>>(
dsAction: _detailsAction, dsAction: _detailsAction!,
builder: (BuildContext context, child) { builder: (BuildContext context, child) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: _buildBody(context,controller: scrollController, detailsVo: _detailsAction.vm), body: _buildBody(context,controller: scrollController, detailsVo: _detailsAction!.vm!),
bottomNavigationBar: _buildNavigationBar(detailsVo: _detailsAction.vm, detailsAction: _detailsAction), bottomNavigationBar: _buildNavigationBar(detailsVo: _detailsAction!.vm!, detailsAction: _detailsAction),
); );
}, },
); );
...@@ -445,18 +446,18 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -445,18 +446,18 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
/// 底部按钮区域 /// 底部按钮区域
/// ///
Widget _buildNavigationBar({ Widget _buildNavigationBar({
@required PriceDetailsVo detailsVo, required PriceDetailsVo detailsVo,
IPriceDetailsAction<PriceDetailsVo> detailsAction, IPriceDetailsAction<PriceDetailsVo>? detailsAction,
}) { }) {
return buildBottomNavWidget( return buildBottomNavWidget(
like: detailsVo?.likeTimes ?? '0', like: detailsVo.likeTimes ?? '0',
favorites: detailsVo?.collegeTimes ?? '0', favorites: detailsVo.collegeTimes ?? '0',
isLike: detailsVo?.isLike ?? false, isLike: detailsVo.isLike,
status: detailsVo.status, status: detailsVo.status,
isFavorites: detailsVo?.isFavorites ?? false, isFavorites: detailsVo.isFavorites,
text: detailsVo.viewState == DSViewState.busy text: detailsVo.viewState == DSViewState.busy
? '加载中' ? '加载中'
: detailsVo?.buttonText ?? '', : detailsVo.buttonText ?? '',
extras: { extras: {
'platform': detailsVo.platform, 'platform': detailsVo.platform,
'item_id': detailsVo.itemId, 'item_id': detailsVo.itemId,
...@@ -471,9 +472,9 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -471,9 +472,9 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
/// ///
/// 如果是淘宝、天猫、和拼多多需要提示授权 /// 如果是淘宝、天猫、和拼多多需要提示授权
/// ///
detailsAction.goToBuyEvent().then((value) { detailsAction!.goToBuyEvent().then((value) {
if (value != null && widget.onH5Callback != null) { if (value != null && widget.onH5Callback != null) {
widget.onH5Callback(value.appLink, value.platform); widget.onH5Callback!(value.appLink, value.platform);
} }
}).catchError((error) { }).catchError((error) {
if (error is DSNetException) { if (error is DSNetException) {
...@@ -483,19 +484,19 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -483,19 +484,19 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
}); });
}, },
onFavoritesTap: () { onFavoritesTap: () {
detailsAction.userCollect(status: detailsVo?.isFavorites ?? false); detailsAction!.userCollect(status: detailsVo.isFavorites);
if (detailsVo?.isFavorites ?? false) { if (detailsVo.isFavorites) {
favoritesValueNotifier.value = 0; favoritesValueNotifier.value = 0;
} else { } else {
favoritesAnimationController.forward(from: 0); favoritesAnimationController!.forward(from: 0);
} }
}, },
onLikeTap: () { onLikeTap: () {
detailsAction.userLike(status: detailsVo?.isLike ?? false); detailsAction!.userLike(status: detailsVo.isLike);
if (detailsVo?.isLike ?? false) { if (detailsVo.isLike) {
likeValueNotifier.value = 0; likeValueNotifier.value = 0;
} else { } else {
likeAnimationController.forward(from: 0); likeAnimationController!.forward(from: 0);
} }
}, },
); );
...@@ -505,13 +506,13 @@ class _PriceDetailsPageState extends State<PriceDetailsPage> ...@@ -505,13 +506,13 @@ class _PriceDetailsPageState extends State<PriceDetailsPage>
void dispose() { void dispose() {
likeAnimationController?.dispose(); likeAnimationController?.dispose();
favoritesAnimationController?.dispose(); favoritesAnimationController?.dispose();
likeValueNotifier?.dispose(); likeValueNotifier.dispose();
favoritesValueNotifier?.dispose(); favoritesValueNotifier.dispose();
super.dispose(); super.dispose();
} }
@override @override
void showTipsMsg({String msg}) { void showTipsMsg({required String msg}) {
FlutterNativeToast.showToast(msg); FlutterNativeToast.showToast(msg);
} }
} }
...@@ -19,7 +19,7 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -19,7 +19,7 @@ import 'package:common_module/utils/xapp_utils.dart';
/// ///
class PriceDiscountPage extends StatefulWidget { class PriceDiscountPage extends StatefulWidget {
final Map<String, dynamic> pageParam; final Map<String, dynamic> pageParam;
const PriceDiscountPage({Key key, @required this.pageParam}) const PriceDiscountPage({Key? key, required this.pageParam})
: super(key: key); : super(key: key);
@override @override
_PriceDiscountPageState createState() => _PriceDiscountPageState(); _PriceDiscountPageState createState() => _PriceDiscountPageState();
...@@ -27,10 +27,10 @@ class PriceDiscountPage extends StatefulWidget { ...@@ -27,10 +27,10 @@ class PriceDiscountPage extends StatefulWidget {
class _PriceDiscountPageState extends State<PriceDiscountPage> class _PriceDiscountPageState extends State<PriceDiscountPage>
with IPriceDiscountDelegate { with IPriceDiscountDelegate {
IPriceDiscountAction _discountAction; IPriceDiscountAction? _discountAction;
bool _isAudituser = false; bool? _isAudituser = false;
List<dynamic> _sellReportList; List<dynamic>? _sellReportList;
@override @override
void initState() { void initState() {
_isAudituser = widget.pageParam['isAudituser']; _isAudituser = widget.pageParam['isAudituser'];
...@@ -49,30 +49,30 @@ class _PriceDiscountPageState extends State<PriceDiscountPage> ...@@ -49,30 +49,30 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DSProviderWidget<PriceDiscountVo, return DSProviderWidget<PriceDiscountVo,
IPriceDiscountAction<PriceDiscountVo>>( IPriceDiscountAction<PriceDiscountVo>>(
dsAction: _discountAction, dsAction: _discountAction as IPriceDiscountAction<PriceDiscountVo>,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Scaffold( return Scaffold(
appBar: buildAppBar(), appBar: buildAppBar() as PreferredSizeWidget,
body: _buildBody1(vo: _discountAction.getVo), body: _buildBody1(vo: _discountAction!.getVo),
); );
}, },
); );
} }
Widget _buildBody1({PriceDiscountVo vo}) { Widget _buildBody1({required PriceDiscountVo vo}) {
return PullWidget( return PullWidget(
controller: _refreshController, controller: _refreshController,
child: Container(child: _buildBody(vo: vo)), child: Container(child: _buildBody(vo: vo)),
onRefresh: () { onRefresh: () {
_discountAction.reloadData(); _discountAction!.reloadData();
}, },
onLoad: () { onLoad: () {
_discountAction.onLoad(); _discountAction!.onLoad();
}, },
); );
} }
Widget _buildBody({PriceDiscountVo vo}) { Widget _buildBody({required PriceDiscountVo vo}) {
if (vo.viewState == DSViewState.busy) { if (vo.viewState == DSViewState.busy) {
return LoadingPage( return LoadingPage(
padding: EdgeInsets.all(13.w), padding: EdgeInsets.all(13.w),
...@@ -86,7 +86,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage> ...@@ -86,7 +86,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
vo.viewState == DSViewState.empty ? '未发现数据,请刷新重试' : '加载失败,请刷新重试', vo.viewState == DSViewState.empty ? '未发现数据,请刷新重试' : '加载失败,请刷新重试',
onReloadTap: () { onReloadTap: () {
//重新加载数据 //重新加载数据
_discountAction.reloadData(); _discountAction!.reloadData();
}, },
); );
} }
...@@ -127,7 +127,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage> ...@@ -127,7 +127,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
} }
@override @override
void onloadFailed({bool isLoading = true, String msg}) { void onloadFailed({bool isLoading = true, String? msg}) {
if (isLoading) { if (isLoading) {
_refreshController.loadFailed(); _refreshController.loadFailed();
} else { } else {
......
...@@ -20,7 +20,7 @@ abstract class PricePageDelegate { ...@@ -20,7 +20,7 @@ abstract class PricePageDelegate {
/// [type] 1、白菜专区 2、爆单页面 3、搜索页面 4、商品详情 /// [type] 1、白菜专区 2、爆单页面 3、搜索页面 4、商品详情
/// [data] 当[type]等于4时,[data]为传递的数据 /// [data] 当[type]等于4时,[data]为传递的数据
/// ///
void onRouteTap({@required String type, Map<String, dynamic> data}); void onRouteTap({required String type, Map<String, dynamic>? data});
/// ///
/// 获取好价的快捷Tab /// 获取好价的快捷Tab
...@@ -29,11 +29,11 @@ abstract class PricePageDelegate { ...@@ -29,11 +29,11 @@ abstract class PricePageDelegate {
} }
class PricePage extends StatefulWidget { class PricePage extends StatefulWidget {
final PricePageDelegate pageDelegate; final PricePageDelegate? pageDelegate;
final List<dynamic> priceCategory; final List<dynamic>? priceCategory;
final Map<int, dynamic> platformIconMap; final Map<int, dynamic>? platformIconMap;
const PricePage( const PricePage(
{Key key, this.pageDelegate, this.platformIconMap, this.priceCategory}) {Key? key, this.pageDelegate, this.platformIconMap, this.priceCategory})
: super(key: key); : super(key: key);
@override @override
_PricePageState createState() => _PricePageState(); _PricePageState createState() => _PricePageState();
...@@ -41,14 +41,14 @@ class PricePage extends StatefulWidget { ...@@ -41,14 +41,14 @@ class PricePage extends StatefulWidget {
class _PricePageState extends BaseUmengPageViewItemState<PricePage> class _PricePageState extends BaseUmengPageViewItemState<PricePage>
with IPriceActionDelegate { with IPriceActionDelegate {
IPriceAction<PriceVo> _priceAction; IPriceAction<PriceVo>? _priceAction;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_priceAction = PriceAction(delegate: this); _priceAction = PriceAction(delegate: this);
_priceAction.setPriceCategory( _priceAction!.setPriceCategory(
sellingTabList: widget.pageDelegate.sellingTabList, sellingTabList: widget.pageDelegate!.sellingTabList,
priceCategory: widget.priceCategory, priceCategory: widget.priceCategory,
platformIconMap: widget.platformIconMap); platformIconMap: widget.platformIconMap);
} }
...@@ -57,7 +57,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -57,7 +57,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>( return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>(
dsAction: _priceAction, dsAction: _priceAction!,
builder: (BuildContext context, child) { builder: (BuildContext context, child) {
return Scaffold( return Scaffold(
backgroundColor: Color(0xFFF5F5F5), backgroundColor: Color(0xFFF5F5F5),
...@@ -65,12 +65,12 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -65,12 +65,12 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
onSearchTap: () { onSearchTap: () {
widget.pageDelegate?.onRouteTap(type: '3'); widget.pageDelegate?.onRouteTap(type: '3');
}, },
isGrid: _priceAction.vm?.productListVo?.isGrid ?? false, isGrid: _priceAction!.vm?.productListVo?.isGrid ?? false,
onLayoutTap: (bool isGrid) async { onLayoutTap: (bool isGrid) async {
_priceAction.vm?.productListVo?.isGrid = isGrid ?? true; _priceAction!.vm?.productListVo?.isGrid = isGrid;
_priceAction.vm?.notifyListener(true); _priceAction!.vm?.notifyListener(true);
}), }) as PreferredSizeWidget?,
body: _buildBody(action: _priceAction), body: _buildBody(action: _priceAction!),
); );
}); });
} }
...@@ -81,7 +81,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -81,7 +81,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
ValueNotifier<double> backColorListenable = ValueNotifier<double>(136.0.w); ValueNotifier<double> backColorListenable = ValueNotifier<double>(136.0.w);
GlobalKey anchorKey = GlobalKey(); GlobalKey anchorKey = GlobalKey();
Widget _buildBody({IPriceAction<PriceVo> action}) { Widget _buildBody({required IPriceAction<PriceVo> action}) {
return Stack( return Stack(
children: [ children: [
// 底部设置一个背景跟随滑动 // 底部设置一个背景跟随滑动
...@@ -105,33 +105,33 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -105,33 +105,33 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
DSProvider.value( DSProvider.value(
vo: action.getTabListVo(), vo: action.getTabListVo(),
builderWidget: (BuildContext context, TabListVo tabListVo, builderWidget: (BuildContext context, TabListVo tabListVo,
Widget child) { Widget? child) {
return buildCategoryTapWidget( return buildCategoryTapWidget(
action.getTabListVo().tabList ?? [], action.getTabListVo().tabList,
action.sellingTabs, action.sellingTabs,
anchorKey: anchorKey, anchorKey: anchorKey,
sellTab: tabListVo.sellTab, sellTab: tabListVo.sellTab,
onChange: (int index, bool enable) { onChange: (int index, bool enable) {
tabListVo?.tabList[index].open = enable; tabListVo.tabList[index].open = enable;
tabListVo.notifyListener(true); tabListVo.notifyListener(true);
}, onChangeSort: (Map<String, dynamic> data) { }, onChangeSort: (Map<String, dynamic> data) {
tabListVo.sellTab = data; tabListVo.sellTab = data;
tabListVo.notifyListener(true); tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(page: 1); _priceAction!.qryProductListEvent(page: 1);
double offset = _scrollViewController.offset; double offset = _scrollViewController.offset;
if (offset > 70.w) { if (offset > 70.w) {
_scrollViewController.animateTo(70.w, _scrollViewController.animateTo(70.w,
duration: Duration(milliseconds: 50), duration: Duration(milliseconds: 50),
curve: Curves.linear); curve: Curves.linear);
} }
}, onNodeChange: (int index, TabVo tabVo) { }, onNodeChange: (int? index, TabVo tabVo) {
tabVo.open = false; tabVo.open = false;
if (tabVo.selected != null && if (tabVo.selected != null &&
tabVo.selected['is_default'] == '1') { tabVo.selected!['is_default'] == '1') {
tabVo.selected = null; tabVo.selected = null;
} }
tabListVo.notifyListener(true); tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(page: 1); _priceAction!.qryProductListEvent(page: 1);
double offset = _scrollViewController.offset; double offset = _scrollViewController.offset;
if (offset > 70.w) { if (offset > 70.w) {
_scrollViewController.animateTo(70.w, _scrollViewController.animateTo(70.w,
...@@ -145,7 +145,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -145,7 +145,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
child: DSProvider.value( child: DSProvider.value(
vo: action.getProductListVo(), vo: action.getProductListVo(),
builderWidget: (BuildContext context, builderWidget: (BuildContext context,
ProductListVo productListVo, Widget child) { ProductListVo productListVo, Widget? child) {
if (productListVo.productList.isEmpty) { if (productListVo.productList.isEmpty) {
if (productListVo.viewState == DSViewState.busy) { if (productListVo.viewState == DSViewState.busy) {
return LoadingPage( return LoadingPage(
...@@ -211,10 +211,10 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -211,10 +211,10 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
], ],
), ),
onLoad: () { onLoad: () {
action?.loadMore(); action.loadMore();
}, },
onRefresh: () { onRefresh: () {
action?.onRefresh(); action.onRefresh();
}, },
controller: _refreshController, controller: _refreshController,
), ),
...@@ -229,7 +229,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -229,7 +229,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
} else if (scroll.metrics.pixels <= 500 && scrollIndex.value == 1) { } else if (scroll.metrics.pixels <= 500 && scrollIndex.value == 1) {
scrollIndex.value = 0; scrollIndex.value = 0;
} }
RenderBox renderBox = anchorKey.currentContext.findRenderObject(); RenderBox renderBox = anchorKey.currentContext!.findRenderObject() as RenderBox;
var offset = var offset =
renderBox.localToGlobal(Offset(0.0, renderBox.size.height)); renderBox.localToGlobal(Offset(0.0, renderBox.size.height));
if (scroll.runtimeType == ScrollStartNotification) { if (scroll.runtimeType == ScrollStartNotification) {
...@@ -270,7 +270,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage> ...@@ -270,7 +270,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
} }
@override @override
void onloadFailed({String msg}) { void onloadFailed({String? msg}) {
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshCompleted(resetFooterState: true); _refreshController.refreshCompleted(resetFooterState: true);
} }
......
...@@ -24,14 +24,14 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart'; ...@@ -24,14 +24,14 @@ import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
/// [actions] action /// [actions] action
/// ///
Widget buildAppBar(BuildContext context, Widget buildAppBar(BuildContext context,
{@required PriceDetailsVo detailsVo, {required PriceDetailsVo detailsVo,
bool audituser = false, bool? audituser = false,
String title = '', String title = '',
ValueListenable<int> listenable, required ValueListenable<int> listenable,
void Function({PriceDetailsVo detailsVo}) onSharePressed}) { void Function(PriceDetailsVo detailsVo)? onSharePressed}) {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: listenable, valueListenable: listenable,
builder: (BuildContext context, int value, Widget child) { builder: (BuildContext context, int value, Widget? child) {
return Container( return Container(
height: 48.w + MediaQuery.of(context).padding.top, height: 48.w + MediaQuery.of(context).padding.top,
child: AppBar( child: AppBar(
...@@ -51,11 +51,11 @@ Widget buildAppBar(BuildContext context, ...@@ -51,11 +51,11 @@ Widget buildAppBar(BuildContext context,
Navigator.maybePop(context); Navigator.maybePop(context);
}, },
), ),
actions: audituser actions: audituser!
? [] ? []
: [IconButton( : [IconButton(
icon: Image.asset('assets/images/ic_btn_share1.png',package: 'price_module',width: 26.w), icon: Image.asset('assets/images/ic_btn_share1.png',package: 'price_module',width: 26.w),
onPressed: () => onSharePressed(detailsVo: detailsVo) onPressed: () => onSharePressed!(detailsVo)
)], )],
)); ));
}, },
...@@ -67,10 +67,10 @@ Widget buildAppBar(BuildContext context, ...@@ -67,10 +67,10 @@ Widget buildAppBar(BuildContext context,
/// ///
/// ///
Widget buildBody(BuildContext context, Widget buildBody(BuildContext context,
{@required ScrollController controller, {required ScrollController controller,
@required List<Widget> slivers, required List<Widget> slivers,
PointerMoveEventListener onPointerMove, PointerMoveEventListener? onPointerMove,
PointerUpEventListener onPointerUp}) { PointerUpEventListener? onPointerUp}) {
return Listener( return Listener(
onPointerMove: onPointerMove, onPointerMove: onPointerMove,
onPointerUp: onPointerUp, onPointerUp: onPointerUp,
...@@ -88,7 +88,7 @@ Widget buildBody(BuildContext context, ...@@ -88,7 +88,7 @@ Widget buildBody(BuildContext context,
/// 好价商品详情滚动栏图片 /// 好价商品详情滚动栏图片
/// [images] 滚动栏图片 /// [images] 滚动栏图片
/// ///
Widget buildSwiperWidget({List<String> images}) { Widget buildSwiperWidget({List<String?>? images}) {
Widget _swiperWidget; Widget _swiperWidget;
int length = (images?.length ?? 0); int length = (images?.length ?? 0);
if (length <= 0) { if (length <= 0) {
...@@ -98,17 +98,17 @@ Widget buildSwiperWidget({List<String> images}) { ...@@ -98,17 +98,17 @@ Widget buildSwiperWidget({List<String> images}) {
width: 200, width: 200,
); );
} else if (length == 1) { } else if (length == 1) {
_swiperWidget = _buildCachedImage(image: images[0]); _swiperWidget = _buildCachedImage(image: images![0]!);
} else { } else {
_swiperWidget = Swiper( _swiperWidget = Swiper(
itemCount: length, itemCount: length,
loop: false, loop: false,
autoplay: false, autoplay: false,
autoplayDelay: 5 * 1000, autoplayDelay: 5 * 1000,
onIndexChanged: (int index) {}, onIndexChanged: (int? index) {},
pagination: _buildSwiperPlugin(), pagination: _buildSwiperPlugin(),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
String image = images[index]; String image = images![index]!;
return _buildCachedImage(image: image); return _buildCachedImage(image: image);
}, },
); );
...@@ -120,7 +120,7 @@ Widget buildSwiperWidget({List<String> images}) { ...@@ -120,7 +120,7 @@ Widget buildSwiperWidget({List<String> images}) {
); );
} }
Widget _buildCachedImage({String image}) { Widget _buildCachedImage({required String image}) {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: image, imageUrl: image,
placeholder: (BuildContext c, String s) { placeholder: (BuildContext c, String s) {
...@@ -134,7 +134,7 @@ Widget _buildCachedImage({String image}) { ...@@ -134,7 +134,7 @@ Widget _buildCachedImage({String image}) {
dynamic _buildSwiperPlugin() { dynamic _buildSwiperPlugin() {
return SwiperCustomPagination( return SwiperCustomPagination(
builder: (BuildContext context, SwiperPluginConfig config) { builder: (BuildContext context, SwiperPluginConfig? config) {
return Positioned( return Positioned(
bottom: 0.w, bottom: 0.w,
right: 0.w, right: 0.w,
...@@ -146,7 +146,7 @@ dynamic _buildSwiperPlugin() { ...@@ -146,7 +146,7 @@ dynamic _buildSwiperPlugin() {
color: Color(0xFF979797), color: Color(0xFF979797),
borderRadius: BorderRadius.circular(10.w)), borderRadius: BorderRadius.circular(10.w)),
child: Text( child: Text(
'${config.activeIndex + 1}/${config.itemCount}', '${config!.activeIndex! + 1}/${config.itemCount}',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 12.w, fontSize: 12.w,
...@@ -166,13 +166,13 @@ dynamic _buildSwiperPlugin() { ...@@ -166,13 +166,13 @@ dynamic _buildSwiperPlugin() {
/// ///
Widget buildSliverAppBar( Widget buildSliverAppBar(
{double top = 0, {double top = 0,
@required Widget leading, required Widget leading,
Widget action, required Widget action,
@required bool isBusy, required bool isBusy,
String title, required String title,
@required double expandedHeight, required double expandedHeight,
@required int itemCount, required int itemCount,
@required IndexedWidgetBuilder itemBuilder}) { required IndexedWidgetBuilder itemBuilder}) {
return SliverAppBar( return SliverAppBar(
elevation: 0.1, elevation: 0.1,
backgroundColor: isBusy ? Color(0xFFE9E9E9) : Colors.white, backgroundColor: isBusy ? Color(0xFFE9E9E9) : Colors.white,
...@@ -200,7 +200,7 @@ Widget buildSliverAppBar( ...@@ -200,7 +200,7 @@ Widget buildSliverAppBar(
autoplay: true, autoplay: true,
autoplayDelay: 5 * 1000, autoplayDelay: 5 * 1000,
itemBuilder: itemBuilder, itemBuilder: itemBuilder,
onIndexChanged: (int index) {}, onIndexChanged: (int? index) {},
pagination: _buildCustomPagination(), pagination: _buildCustomPagination(),
), ),
))); )));
...@@ -209,7 +209,7 @@ Widget buildSliverAppBar( ...@@ -209,7 +209,7 @@ Widget buildSliverAppBar(
/// ///
/// 商品详情部分 /// 商品详情部分
/// ///
Widget buildDetailsWidget({@required List<Widget> children}) { Widget buildDetailsWidget({required List<Widget> children}) {
return SliverToBoxAdapter( return SliverToBoxAdapter(
child: Container( child: Container(
color: Colors.white, color: Colors.white,
...@@ -228,8 +228,8 @@ Widget buildDetailsWidget({@required List<Widget> children}) { ...@@ -228,8 +228,8 @@ Widget buildDetailsWidget({@required List<Widget> children}) {
/// [expired] 是否过期 /// [expired] 是否过期
/// ///
Widget buildTitleWidget({ Widget buildTitleWidget({
@required String title, required String title,
@required String subTitle, required String subTitle,
bool expired = false, bool expired = false,
}) { }) {
return Container( return Container(
...@@ -266,15 +266,15 @@ Widget buildTitleWidget({ ...@@ -266,15 +266,15 @@ Widget buildTitleWidget({
/// 商品信息 /// 商品信息
/// ///
Widget buildStoreInfoWidget( Widget buildStoreInfoWidget(
{@required PriceDetailsVo vo, {required PriceDetailsVo vo,
void Function(Coupon) onCouponTap, void Function(Coupon)? onCouponTap,
void Function(Map<String, dynamic>) onPurchase}) { void Function(Map<String, dynamic>)? onPurchase}) {
if ((vo.shopTitle ?? '').isEmpty) { if ((vo.shopTitle ?? '').isEmpty) {
return Container(); return Container();
} }
/// 凑单购买 /// 凑单购买
Widget getCollectOrders({List<dynamic> orders}) { Widget getCollectOrders({required List<dynamic> orders}) {
Widget getOrdersItemWidget(dynamic data) { Widget getOrdersItemWidget(dynamic data) {
return InkWell( return InkWell(
child: Container( child: Container(
...@@ -322,9 +322,9 @@ Widget buildStoreInfoWidget( ...@@ -322,9 +322,9 @@ Widget buildStoreInfoWidget(
/// 优惠卷Widget /// 优惠卷Widget
/// [coupon] 优惠卷 /// [coupon] 优惠卷
/// ///
Widget getCouponWidget({Coupon coupon}) { Widget getCouponWidget({required Coupon coupon}) {
return InkWell(child:RichText(text: TextSpan(children:[ return InkWell(child:RichText(text: TextSpan(children:[
WidgetSpan(child:Container(height:16.w,child:Text(coupon.name,style: TextStyle(color:Color(coupon.status == '1' ? 0xFFFF0400 : 0xFF999999),fontSize: 12.w)),),), WidgetSpan(child:Container(height:16.w,child:Text(coupon.name!,style: TextStyle(color:Color(coupon.status == '1' ? 0xFFFF0400 : 0xFF999999),fontSize: 12.w)),),),
WidgetSpan(child:Container( WidgetSpan(child:Container(
width: 16.w, width: 16.w,
alignment:Alignment.centerLeft, alignment:Alignment.centerLeft,
...@@ -361,7 +361,7 @@ Widget buildStoreInfoWidget( ...@@ -361,7 +361,7 @@ Widget buildStoreInfoWidget(
width: 0.5.w, width: 0.5.w,
height: 13.w, height: 13.w,
), ),
Text(vo.shopTitle, Text(vo.shopTitle!,
style: TextStyle(fontSize: 12.w, color: Color(0xFF302600))), style: TextStyle(fontSize: 12.w, color: Color(0xFF302600))),
], ],
), ),
...@@ -380,7 +380,7 @@ Widget buildStoreInfoWidget( ...@@ -380,7 +380,7 @@ Widget buildStoreInfoWidget(
), ),
Container( Container(
width: 280.w, width: 280.w,
child: getCollectOrders(orders: vo.collectOrders), child: getCollectOrders(orders: vo.collectOrders!),
), ),
], ],
), ),
...@@ -391,7 +391,7 @@ Widget buildStoreInfoWidget( ...@@ -391,7 +391,7 @@ Widget buildStoreInfoWidget(
: Container(), : Container(),
//优惠 //优惠
(vo.coupons?.length ?? 0) > 0 vo.coupons.length > 0
? Container( ? Container(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
...@@ -409,7 +409,7 @@ Widget buildStoreInfoWidget( ...@@ -409,7 +409,7 @@ Widget buildStoreInfoWidget(
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
runSpacing:6.w, runSpacing:6.w,
children: List.generate( children: List.generate(
vo.coupons?.length ?? 0, vo.coupons.length,
(index) => getCouponWidget( (index) => getCouponWidget(
coupon: vo.coupons[index], coupon: vo.coupons[index],
), ),
...@@ -442,7 +442,7 @@ Widget buildStoreInfoWidget( ...@@ -442,7 +442,7 @@ Widget buildStoreInfoWidget(
bottomRight: Radius.circular(8.0), bottomRight: Radius.circular(8.0),
topRight: Radius.circular(8.0), topRight: Radius.circular(8.0),
topLeft: Radius.circular(8.0))), topLeft: Radius.circular(8.0))),
child: Text(vo.rebate, child: Text(vo.rebate!,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 11.w, fontSize: 11.w,
...@@ -460,13 +460,13 @@ Widget buildStoreInfoWidget( ...@@ -460,13 +460,13 @@ Widget buildStoreInfoWidget(
/// 商品信息 /// 商品信息
/// ///
Widget buildProductNewlastWidget( Widget buildProductNewlastWidget(
{@required Map<String, dynamic> newInfo, {required Map<String, dynamic>? newInfo,
void Function() goBuy, void Function()? goBuy,
void Function(Map<String, dynamic>) onCouponTap}) { void Function(Map<String, dynamic>)? onCouponTap}) {
if (newInfo == null) { if (newInfo == null) {
return Container(); return Container();
} }
List<dynamic> couponInfo = []; List<dynamic>? couponInfo = [];
if (newInfo['coupon_info'] is List) { if (newInfo['coupon_info'] is List) {
couponInfo = newInfo['coupon_info']; couponInfo = newInfo['coupon_info'];
} }
...@@ -533,7 +533,7 @@ Widget buildProductNewlastWidget( ...@@ -533,7 +533,7 @@ Widget buildProductNewlastWidget(
onTap: goBuy), onTap: goBuy),
], ],
), ),
couponInfo.isNotEmpty couponInfo!.isNotEmpty
? SizedBox( ? SizedBox(
height: 4.w, height: 4.w,
) )
...@@ -554,7 +554,7 @@ Widget buildProductNewlastWidget( ...@@ -554,7 +554,7 @@ Widget buildProductNewlastWidget(
itemCount: couponInfo.length, itemCount: couponInfo.length,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
Map<String, dynamic> data = couponInfo[index]; Map<String, dynamic> data = couponInfo![index];
return InkWell( return InkWell(
child: Container( child: Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
...@@ -602,18 +602,18 @@ Widget buildProductNewlastWidget( ...@@ -602,18 +602,18 @@ Widget buildProductNewlastWidget(
/// [onReceiveTap] 点击领取优惠卷 /// [onReceiveTap] 点击领取优惠卷
/// ///
Widget buildCouponWidget(BuildContext context, Widget buildCouponWidget(BuildContext context,
{@required List<Coupon> coupons, {required List<Coupon?> coupons,
@required String couponText, required String couponText,
@required Function(Coupon) onReceiveTap}) { required Function(Coupon) onReceiveTap}) {
if (coupons == null || coupons.isEmpty) { if (coupons.isEmpty) {
return Container(); return Container();
} }
/// ///
/// 优惠卷全部过期 /// 优惠卷全部过期
/// ///
if (couponText != null && couponText.isNotEmpty) { if (couponText.isNotEmpty) {
Coupon coupon; Coupon? coupon;
try { try {
coupon = coupon =
coupons.singleWhere((ele) => '${ele?.status}' == '1', orElse: () { coupons.singleWhere((ele) => '${ele?.status}' == '1', orElse: () {
...@@ -654,7 +654,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -654,7 +654,7 @@ Widget buildCouponWidget(BuildContext context,
runSpacing:6.rpx, runSpacing:6.rpx,
children: children:
List<Widget>.generate(coupons.length, (index) { List<Widget>.generate(coupons.length, (index) {
Coupon coupon = coupons[index]; Coupon coupon = coupons[index]!;
return Container( return Container(
child: Text( child: Text(
'${coupon.name}', '${coupon.name}',
...@@ -780,7 +780,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -780,7 +780,7 @@ Widget buildCouponWidget(BuildContext context,
), ),
])); ]));
} }
Coupon coupon = coupons[index - 1]; Coupon coupon = coupons[index - 1]!;
return Container( return Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: 13.w, left: 13.w,
...@@ -797,7 +797,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -797,7 +797,7 @@ Widget buildCouponWidget(BuildContext context,
child: Row(children: [ child: Row(children: [
Expanded( Expanded(
child: Text( child: Text(
coupon.name, coupon.name!,
style: TextStyle( style: TextStyle(
fontSize: 15.w, fontSize: 15.w,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
...@@ -829,8 +829,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -829,8 +829,7 @@ Widget buildCouponWidget(BuildContext context,
.circular(16.w))), .circular(16.w))),
), ),
onTap: () { onTap: () {
if (onReceiveTap != null && if (coupon.status == '1') {
coupon.status == '1') {
onReceiveTap(coupon); onReceiveTap(coupon);
Navigator.maybePop(context); Navigator.maybePop(context);
} }
...@@ -861,7 +860,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -861,7 +860,7 @@ Widget buildCouponWidget(BuildContext context,
child: Wrap( child: Wrap(
runSpacing: 6.rpx, runSpacing: 6.rpx,
children: List<Widget>.generate(coupons.length, (index) { children: List<Widget>.generate(coupons.length, (index) {
Coupon coupon = coupons[index]; Coupon coupon = coupons[index]!;
return Container( return Container(
child: Text( child: Text(
'${coupon.name}', '${coupon.name}',
...@@ -958,7 +957,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -958,7 +957,7 @@ Widget buildCouponWidget(BuildContext context,
), ),
])); ]));
} }
Coupon coupon = coupons[index - 1]; Coupon coupon = coupons[index - 1]!;
return Container( return Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: 13.w, left: 13.w,
...@@ -975,7 +974,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -975,7 +974,7 @@ Widget buildCouponWidget(BuildContext context,
child: Row(children: [ child: Row(children: [
Expanded( Expanded(
child: Text( child: Text(
coupon.name, coupon.name!,
style: TextStyle( style: TextStyle(
fontSize: 15.w, fontSize: 15.w,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
...@@ -1003,8 +1002,7 @@ Widget buildCouponWidget(BuildContext context, ...@@ -1003,8 +1002,7 @@ Widget buildCouponWidget(BuildContext context,
Radius.circular(16.w))), Radius.circular(16.w))),
), ),
onTap: () { onTap: () {
if (onReceiveTap != null && if (coupon.status == '1') {
coupon.status == '1') {
onReceiveTap(coupon); onReceiveTap(coupon);
Navigator.maybePop(context); Navigator.maybePop(context);
} }
...@@ -1022,17 +1020,17 @@ Widget buildCouponWidget(BuildContext context, ...@@ -1022,17 +1020,17 @@ Widget buildCouponWidget(BuildContext context,
/// [html] 商品图文信息 /// [html] 商品图文信息
/// ///
Widget buildProductDetailsWidget(BuildContext context, Widget buildProductDetailsWidget(BuildContext context,
{@required String html}) { {required String html}) {
return Container( return Container(
margin: EdgeInsets.only(top: 16.w, bottom: 4.w, left: 4.w, right: 4.w), margin: EdgeInsets.only(top: 16.w, bottom: 4.w, left: 4.w, right: 4.w),
child: Html( child: Html(
data: html, data: html,
style: {}, style: {},
customRender: {}, customRender: {},
onLinkTap:(String url,RenderContext context,Map<String, String> attributes,dom.Element element) { onLinkTap:(String? url,RenderContext context,Map<String, String> attributes,dom.Element? element) {
print("=========>onLinkTap $url"); print("=========>onLinkTap $url");
}, },
onImageTap:(String url,RenderContext context,Map<String, String> attributes,dom.Element element) { onImageTap:(String? url,RenderContext context,Map<String, String> attributes,dom.Element? element) {
print("=========>onImageTap $url"); print("=========>onImageTap $url");
}, },
onImageError: (exception, stackTrace) { onImageError: (exception, stackTrace) {
...@@ -1046,10 +1044,10 @@ Widget buildProductDetailsWidget(BuildContext context, ...@@ -1046,10 +1044,10 @@ Widget buildProductDetailsWidget(BuildContext context,
/// [onReportTap] 举报按钮 /// [onReportTap] 举报按钮
/// ///
Widget buildPromptWidget( Widget buildPromptWidget(
{@required String releaseTime, {required String? releaseTime,
@required String checkText, required String? checkText,
VoidCallback onReportTap, VoidCallback? onReportTap,
Map<String, dynamic> extras}) { Map<String, dynamic>? extras}) {
return Container( return Container(
child: Column( child: Column(
children: [ children: [
...@@ -1093,9 +1091,9 @@ Widget buildPromptWidget( ...@@ -1093,9 +1091,9 @@ Widget buildPromptWidget(
/// 相关优惠信息 /// 相关优惠信息
/// ///
Widget buildRelatedDiscountWidget( Widget buildRelatedDiscountWidget(
{List<ProductItemEntity> productEntitys, {List<ProductItemEntity>? productEntitys,
void Function(ProductItemEntity, int) onItemTap, void Function(ProductItemEntity, int)? onItemTap,
void Function() onMoreTap}) { void Function()? onMoreTap}) {
bool isShowMore = false; bool isShowMore = false;
if (productEntitys == null || productEntitys.length <= 0) { if (productEntitys == null || productEntitys.length <= 0) {
return Container(); return Container();
...@@ -1157,7 +1155,7 @@ Widget buildRelatedDiscountWidget( ...@@ -1157,7 +1155,7 @@ Widget buildRelatedDiscountWidget(
/// 分享弹窗 /// 分享弹窗
/// ///
/// ///
Future<T> showShareModalBottom<T>(BuildContext context,{@required List<Map<String, dynamic>> items,Map<String, dynamic> extras = const {}}) { Future<T?> showShareModalBottom<T>(BuildContext context,{required List<Map<String, dynamic>> items,Map<String, dynamic> extras = const {}}) {
return showPopBottomSheet(context:context,pageName:RoutePath.PRICE_DETAIL_PAGE.path(),items: items,extras: extras); return showPopBottomSheet(context:context,pageName:RoutePath.PRICE_DETAIL_PAGE.path(),items: items,extras: extras);
} }
...@@ -1166,12 +1164,12 @@ Future<T> showShareModalBottom<T>(BuildContext context,{@required List<Map<Strin ...@@ -1166,12 +1164,12 @@ Future<T> showShareModalBottom<T>(BuildContext context,{@required List<Map<Strin
/// [context] 上下文对象 /// [context] 上下文对象
/// [items] 菜单列表 /// [items] 菜单列表
/// ///
Future<T> showReceiveModalBottom<T>(BuildContext context, Future<T?> showReceiveModalBottom<T>(BuildContext context,
{@required List<ReportModel> items}) { {required List<ReportModel> items}) {
return _showModalBottomList(context, itemCount: items.length, return _showModalBottomList(context, itemCount: items.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
Widget widget; Widget widget;
ReportModel reportModel; ReportModel? reportModel;
if (index == items.length) { if (index == items.length) {
widget = Container( widget = Container(
color: Colors.white, color: Colors.white,
...@@ -1194,7 +1192,7 @@ Future<T> showReceiveModalBottom<T>(BuildContext context, ...@@ -1194,7 +1192,7 @@ Future<T> showReceiveModalBottom<T>(BuildContext context,
alignment: Alignment.center, alignment: Alignment.center,
height: 49, height: 49,
child: Text( child: Text(
items[index].text, items[index].text!,
style: TextStyle(fontSize: 15, color: Color(0xFF302600)), style: TextStyle(fontSize: 15, color: Color(0xFF302600)),
), ),
margin: EdgeInsets.only(top: index == 0 ? 0 : 0.6), margin: EdgeInsets.only(top: index == 0 ? 0 : 0.6),
...@@ -1218,21 +1216,21 @@ Future<T> showReceiveModalBottom<T>(BuildContext context, ...@@ -1218,21 +1216,21 @@ Future<T> showReceiveModalBottom<T>(BuildContext context,
/// [onBuyTap] 购买 /// [onBuyTap] 购买
/// ///
Widget buildBottomNavWidget( Widget buildBottomNavWidget(
{@required String like, {required String like,
@required String favorites, required String favorites,
bool isLike = false, bool isLike = false,
bool isFavorites = false, bool isFavorites = false,
@required String text, required String text,
VoidCallback onLikeTap, VoidCallback? onLikeTap,
VoidCallback onFavoritesTap, VoidCallback? onFavoritesTap,
VoidCallback onBuyTap, VoidCallback? onBuyTap,
VoidCallback onShareTap, VoidCallback? onShareTap,
String status, String? status,
Map<String, dynamic> extras, Map<String, dynamic>? extras,
@required List<String> favoritesImages, required List<String> favoritesImages,
@required ValueNotifier<int> favoritesValueNotifier, required ValueNotifier<int> favoritesValueNotifier,
@required List<String> likeImages, required List<String> likeImages,
@required ValueNotifier<int> likeValueNotifier}) { required ValueNotifier<int> likeValueNotifier}) {
if (isLike) { if (isLike) {
likeValueNotifier.value = likeImages.length - 1; likeValueNotifier.value = likeImages.length - 1;
} else { } else {
...@@ -1273,7 +1271,7 @@ Widget buildBottomNavWidget( ...@@ -1273,7 +1271,7 @@ Widget buildBottomNavWidget(
), ),
], ],
), ),
AuditModeUtils.getInstance().isAuditMode()?Container(width:1):InkWell( AuditModeUtils.getInstance()!.isAuditMode()?Container(width:1):InkWell(
child: Container( child: Container(
margin: EdgeInsets.only(right: 24.w, left: 10.w), margin: EdgeInsets.only(right: 24.w, left: 10.w),
child: Column( child: Column(
...@@ -1307,16 +1305,16 @@ Widget buildBottomNavWidget( ...@@ -1307,16 +1305,16 @@ Widget buildBottomNavWidget(
} }
Widget _buildAnimationText({ Widget _buildAnimationText({
@required String text, required String text,
ValueNotifier<int> valueNotifier, ValueNotifier<int>? valueNotifier,
double width1, double? width1,
EdgeInsetsGeometry margin, EdgeInsetsGeometry? margin,
String package = 'price_module', String package = 'price_module',
List<String> images, List<String>? images,
double width, double? width,
double height, double? height,
VoidCallback onTap, VoidCallback? onTap,
TextStyle style, TextStyle? style,
}) { }) {
return Container( return Container(
padding: margin, padding: margin,
...@@ -1344,13 +1342,13 @@ Widget _buildAnimationText({ ...@@ -1344,13 +1342,13 @@ Widget _buildAnimationText({
/// [onTap] 点击事件 /// [onTap] 点击事件
/// ///
Widget _buildIconText( Widget _buildIconText(
{@required String image, {required String image,
@required String text, required String text,
double width = 24, double width = 24,
double width1, double? width1,
EdgeInsetsGeometry margin, EdgeInsetsGeometry? margin,
TextStyle style, TextStyle? style,
VoidCallback onTap}) { VoidCallback? onTap}) {
return Container( return Container(
width: width1, width: width1,
padding: margin, padding: margin,
...@@ -1375,7 +1373,7 @@ Widget _buildIconText( ...@@ -1375,7 +1373,7 @@ Widget _buildIconText(
/// ///
SwiperPlugin _buildCustomPagination() { SwiperPlugin _buildCustomPagination() {
return SwiperCustomPagination( return SwiperCustomPagination(
builder: (BuildContext context, SwiperPluginConfig config) { builder: (BuildContext context, SwiperPluginConfig? config) {
return Positioned( return Positioned(
bottom: 12.w, bottom: 12.w,
right: 12.w, right: 12.w,
...@@ -1387,7 +1385,7 @@ SwiperPlugin _buildCustomPagination() { ...@@ -1387,7 +1385,7 @@ SwiperPlugin _buildCustomPagination() {
color: Color.fromRGBO(48, 38, 0, 0.4), color: Color.fromRGBO(48, 38, 0, 0.4),
borderRadius: BorderRadius.circular(10.w)), borderRadius: BorderRadius.circular(10.w)),
child: Text( child: Text(
'${config.activeIndex + 1}/${config.itemCount}', '${config!.activeIndex! + 1}/${config.itemCount}',
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 12.w, fontSize: 12.w,
...@@ -1397,8 +1395,8 @@ SwiperPlugin _buildCustomPagination() { ...@@ -1397,8 +1395,8 @@ SwiperPlugin _buildCustomPagination() {
}); });
} }
Future<T> _showModalBottomList<T>(BuildContext context, Future<T?> _showModalBottomList<T>(BuildContext context,
{@required int itemCount, @required IndexedWidgetBuilder itemBuilder}) { {required int itemCount, required IndexedWidgetBuilder itemBuilder}) {
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
......
...@@ -18,8 +18,8 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -18,8 +18,8 @@ import 'package:common_module/utils/xapp_utils.dart';
/// [onLayoutTap] 布局变化点击事件 /// [onLayoutTap] 布局变化点击事件
/// ///
Widget buildAppBar({ Widget buildAppBar({
@required Function onSearchTap, required Function onSearchTap,
@required Function(bool) onLayoutTap, required Function(bool) onLayoutTap,
bool isGrid = false, bool isGrid = false,
}) { }) {
return buildAppSearchBar( return buildAppSearchBar(
...@@ -38,7 +38,7 @@ Widget buildAppBar({ ...@@ -38,7 +38,7 @@ Widget buildAppBar({
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFFFFFFF), borderRadius: BorderRadius.circular(17.w)), color: Color(0xFFFFFFFF), borderRadius: BorderRadius.circular(17.w)),
child: InkWell( child: InkWell(
onTap: onSearchTap, onTap: onSearchTap as void Function()?,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
...@@ -65,13 +65,13 @@ Widget buildAppBar({ ...@@ -65,13 +65,13 @@ Widget buildAppBar({
right: InkWell( right: InkWell(
child: Image.asset( child: Image.asset(
'assets/images/price_layout_' + 'assets/images/price_layout_' +
((isGrid ?? false) ? 'list' : 'grid') + (isGrid ? 'list' : 'grid') +
'_icon.png', '_icon.png',
package: 'price_module', package: 'price_module',
width: 28.w, width: 28.w,
height: 28.w, height: 28.w,
), ),
onTap: () => onLayoutTap(!(isGrid ?? false)), onTap: () => onLayoutTap(!isGrid),
), ),
); );
} }
...@@ -80,7 +80,7 @@ Widget buildAppBar({ ...@@ -80,7 +80,7 @@ Widget buildAppBar({
/// 专区部分单个Widget /// 专区部分单个Widget
/// [image] 单个Widget的图片 /// [image] 单个Widget的图片
/// ///
Widget _buildZoneItemWidget({@required String image, void Function() onTap}) { Widget _buildZoneItemWidget({required String image, void Function()? onTap}) {
return Expanded( return Expanded(
child: InkWell( child: InkWell(
child: Container( child: Container(
...@@ -107,7 +107,7 @@ Widget _buildZoneItemWidget({@required String image, void Function() onTap}) { ...@@ -107,7 +107,7 @@ Widget _buildZoneItemWidget({@required String image, void Function() onTap}) {
/// 专区Widget /// 专区Widget
/// [onValueTap] 专区点击事件 /// [onValueTap] 专区点击事件
/// ///
Widget buildZoneWidget({void Function(String) onValueTap}) { Widget buildZoneWidget({void Function(String)? onValueTap}) {
return Container( return Container(
margin: EdgeInsets.symmetric(vertical: 8.w, horizontal: 13.w), margin: EdgeInsets.symmetric(vertical: 8.w, horizontal: 13.w),
child: Row( child: Row(
...@@ -140,10 +140,10 @@ Widget buildZoneWidget({void Function(String) onValueTap}) { ...@@ -140,10 +140,10 @@ Widget buildZoneWidget({void Function(String) onValueTap}) {
/// [valueListenable] 数据变化 /// [valueListenable] 数据变化
/// ///
Widget backgroundColorWidget( Widget backgroundColorWidget(
{@required ValueListenable<double> valueListenable}) { {required ValueListenable<double> valueListenable}) {
return ValueListenableBuilder<double>( return ValueListenableBuilder<double>(
valueListenable: valueListenable, valueListenable: valueListenable,
builder: (BuildContext context, double value, Widget child) { builder: (BuildContext context, double value, Widget? child) {
return Positioned( return Positioned(
child: Container( child: Container(
height: 200, height: 200,
...@@ -167,11 +167,11 @@ Widget backgroundColorWidget( ...@@ -167,11 +167,11 @@ Widget backgroundColorWidget(
/// [onPressed] 点击回到顶部按钮 /// [onPressed] 点击回到顶部按钮
/// ///
Widget backTopWidget( Widget backTopWidget(
{@required ValueListenable<int> valueListenable, {required ValueListenable<int> valueListenable,
@required void Function() onPressed}) { required void Function() onPressed}) {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: valueListenable, valueListenable: valueListenable,
builder: (BuildContext context, dynamic value, Widget child) { builder: (BuildContext context, dynamic value, Widget? child) {
if (value == 1) { if (value == 1) {
return Positioned( return Positioned(
bottom: 10.w, bottom: 10.w,
...@@ -186,12 +186,12 @@ Widget backTopWidget( ...@@ -186,12 +186,12 @@ Widget backTopWidget(
} }
Widget buildCustomScroll( Widget buildCustomScroll(
{@required List<Widget> children, {required List<Widget> children,
void Function() onRefresh, void Function()? onRefresh,
void Function() onLoad, void Function()? onLoad,
RefreshController refreshController, RefreshController? refreshController,
@required bool Function(ScrollNotification) onNotification, required bool Function(ScrollNotification) onNotification,
@required ScrollController controller}) { required ScrollController controller}) {
return NotificationListener( return NotificationListener(
onNotification: onNotification, onNotification: onNotification,
child: PullWidget( child: PullWidget(
...@@ -212,10 +212,10 @@ Widget buildCustomScroll( ...@@ -212,10 +212,10 @@ Widget buildCustomScroll(
/// [structure] 分类的数据结构 /// [structure] 分类的数据结构
/// ///
Widget _buildClassifyShowWidget( Widget _buildClassifyShowWidget(
{List<dynamic> structure, {List<dynamic>? structure,
@required void Function(Map<String, dynamic>) onResultTap, required void Function(Map<String, dynamic>) onResultTap,
@required void Function() onResetTap, required void Function() onResetTap,
Map<String, dynamic> selected}) { Map<String?, dynamic>? selected}) {
return ClassifyShowWidget( return ClassifyShowWidget(
selected: selected, selected: selected,
structure: structure, structure: structure,
...@@ -227,7 +227,7 @@ Widget _buildClassifyShowWidget( ...@@ -227,7 +227,7 @@ Widget _buildClassifyShowWidget(
/// ///
/// 商城和最新Tab /// 商城和最新Tab
/// ///
Widget _newestTabWidget({List<dynamic> structure,void Function(int) onChange,Map<String, dynamic> selected}) { Widget _newestTabWidget({required List<dynamic> structure,void Function(int)? onChange,Map<String?, dynamic>? selected}) {
return Container( return Container(
decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.vertical(bottom: Radius.circular(10))), decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.vertical(bottom: Radius.circular(10))),
child: Column( child: Column(
...@@ -259,16 +259,16 @@ Widget _newestTabWidget({List<dynamic> structure,void Function(int) onChange,Map ...@@ -259,16 +259,16 @@ Widget _newestTabWidget({List<dynamic> structure,void Function(int) onChange,Map
/// Tab /// Tab
/// ///
Widget buildTapWidget(BuildContext context, Widget buildTapWidget(BuildContext context,
{@required List<TabVo> tabList, {required List<TabVo> tabList,
void Function(int, bool) onChange, void Function(int, bool)? onChange,
@required void Function(int, TabVo) onNodeChange}) { required void Function(int?, TabVo) onNodeChange}) {
Widget categoryWidget({Widget Function() onHeaderWidget}) { return Container( Widget categoryWidget({Widget Function()? onHeaderWidget}) { return Container(
height: 40.w, height: 40.w,
color: Color(0xFFF5F5F5), color: Color(0xFFF5F5F5),
child: Row( child: Row(
children: List<Widget>.generate(tabList.length, (index) { children: List<Widget>.generate(tabList.length, (index) {
TabVo tabVo = tabList[index]; TabVo tabVo = tabList[index];
String title = getHeaderTitle(tabVo); String? title = getHeaderTitle(tabVo);
return Expanded( return Expanded(
child:OtherWidget( child:OtherWidget(
onHeaderWidget:onHeaderWidget, onHeaderWidget:onHeaderWidget,
...@@ -306,22 +306,20 @@ Widget buildTapWidget(BuildContext context, ...@@ -306,22 +306,20 @@ Widget buildTapWidget(BuildContext context,
onChange(index, true); onChange(index, true);
} }
if (tabVo.type == '3') { if (tabVo.type == '3') {
List<String> tabs = []; List<String?> tabs = [];
tabVo.structure?.forEach((ele) { tabVo.structure?.forEach((ele) {
tabs.add(ele['text']); tabs.add(ele['text']);
}); });
callback( callback(
_newestTabWidget( _newestTabWidget(
structure: tabVo.structure, structure: tabVo.structure!,
onChange: (v) { onChange: (v) {
if (tabVo.structure != null && if (tabVo.structure != null &&
tabVo.structure.length > v) { tabVo.structure!.length > v) {
dynamic data = tabVo.structure[v]; dynamic data = tabVo.structure![v];
tabVo.selected = data; tabVo.selected = data;
if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
}
callback(null); callback(null);
} }
}, },
...@@ -330,20 +328,16 @@ Widget buildTapWidget(BuildContext context, ...@@ -330,20 +328,16 @@ Widget buildTapWidget(BuildContext context,
); );
} else if (tabVo.type == '4') { } else if (tabVo.type == '4') {
callback(_buildPriceShowWidget( callback(_buildPriceShowWidget(
structure: tabVo.structure[0], structure: tabVo.structure![0],
keyName: tabVo.keyName, keyName: tabVo.keyName,
onResultTap: (Map<String, dynamic> data) { onResultTap: (Map<String?, dynamic> data) {
tabVo.selected = data; tabVo.selected = data;
if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
}
callback(null); callback(null);
}, },
onResetTap: () { onResetTap: () {
tabVo.selected = null; tabVo.selected = null;
if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
}
callback(null); callback(null);
}, },
selected: tabVo.selected ?? {}, selected: tabVo.selected ?? {},
...@@ -354,16 +348,12 @@ Widget buildTapWidget(BuildContext context, ...@@ -354,16 +348,12 @@ Widget buildTapWidget(BuildContext context,
structure: tabVo.structure, structure: tabVo.structure,
onResetTap: () { onResetTap: () {
tabVo.selected = null; tabVo.selected = null;
if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
}
callback(null); callback(null);
}, },
onResultTap: (Map<String, dynamic> result) { onResultTap: (Map<String, dynamic> result) {
tabVo.selected = result; tabVo.selected = result;
if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
}
callback(null); callback(null);
})); }));
} }
...@@ -409,11 +399,11 @@ Widget buildTapWidget(BuildContext context, ...@@ -409,11 +399,11 @@ Widget buildTapWidget(BuildContext context,
/// 价格Table /// 价格Table
/// ///
Widget _buildPriceShowWidget( Widget _buildPriceShowWidget(
{Map<String, dynamic> structure, {required Map<String, dynamic> structure,
String keyName, String? keyName,
@required void Function(Map<String, dynamic>) onResultTap, required void Function(Map<String?, dynamic>) onResultTap,
@required void Function() onResetTap, required void Function() onResetTap,
Map<String, dynamic> selected}) { Map<String?, dynamic>? selected}) {
TextEditingController controller1 = TextEditingController(); TextEditingController controller1 = TextEditingController();
TextEditingController controller2 = TextEditingController(); TextEditingController controller2 = TextEditingController();
...@@ -437,7 +427,7 @@ Widget _buildPriceShowWidget( ...@@ -437,7 +427,7 @@ Widget _buildPriceShowWidget(
keyName2 = '${labels[1]['key_name']}'; keyName2 = '${labels[1]['key_name']}';
} }
} }
if (selected[keyName1] is String) { if (selected![keyName1] is String) {
controller1.text = '${selected[keyName1]}'; controller1.text = '${selected[keyName1]}';
} }
if (selected[keyName2] is String) { if (selected[keyName2] is String) {
...@@ -562,11 +552,8 @@ Widget _buildPriceShowWidget( ...@@ -562,11 +552,8 @@ Widget _buildPriceShowWidget(
borderRadius: BorderRadius.circular(8)), borderRadius: BorderRadius.circular(8)),
), ),
onTap: () { onTap: () {
if (onResetTap != null) {
onResetTap(); onResetTap();
}
}), }),
flex: 1, flex: 1,
), ),
SizedBox(width: 12), SizedBox(width: 12),
...@@ -583,31 +570,23 @@ Widget _buildPriceShowWidget( ...@@ -583,31 +570,23 @@ Widget _buildPriceShowWidget(
color: Color(0xFFFFBB00)), color: Color(0xFFFFBB00)),
), ),
onTap: () { onTap: () {
if (onResultTap != null) {
Map<String, dynamic> resultMap = {}; Map<String, dynamic> resultMap = {};
String lowest = controller1.text.trim(); String lowest = controller1.text.trim();
String highest = controller2.text.trim(); String highest = controller2.text.trim();
if (keyName1 != null && if (keyName1.isNotEmpty && lowest.isNotEmpty) {
keyName1.isNotEmpty &&
lowest.isNotEmpty) {
resultMap[keyName1] = lowest; resultMap[keyName1] = lowest;
} }
if (keyName2 != null && if (keyName2.isNotEmpty && highest.isNotEmpty) {
keyName2.isNotEmpty &&
highest.isNotEmpty) {
resultMap[keyName2] = highest; resultMap[keyName2] = highest;
} }
if (resultMap.isEmpty) { if (resultMap.isEmpty) {
onResetTap(); onResetTap();
} else { } else {
Map<String, dynamic> result = { Map<String?, dynamic> result = {'keyName': keyName,keyName: resultMap};
'keyName': keyName,
keyName: resultMap
};
onResultTap(result); onResultTap(result);
} }
} }
}), ),
flex: 3, flex: 3,
), ),
...@@ -620,9 +599,9 @@ Widget _buildPriceShowWidget( ...@@ -620,9 +599,9 @@ Widget _buildPriceShowWidget(
} }
Widget _buildNewestWidget( Widget _buildNewestWidget(
{@required List<dynamic> structure, {required List<dynamic> structure,
@required void Function(int) onChange, required void Function(int) onChange,
Map<String, dynamic> selected}) { Map<String?, dynamic>? selected}) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
...@@ -630,7 +609,7 @@ Widget _buildNewestWidget( ...@@ -630,7 +609,7 @@ Widget _buildNewestWidget(
child: ListView.builder( child: ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shrinkWrap: true, shrinkWrap: true,
itemCount: structure?.length ?? 0, itemCount: structure.length,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
dynamic map = structure[index]; dynamic map = structure[index];
...@@ -649,9 +628,7 @@ Widget _buildNewestWidget( ...@@ -649,9 +628,7 @@ Widget _buildNewestWidget(
color: Color(enable ? 0xFFFF8000 : 0xFF666666))), color: Color(enable ? 0xFFFF8000 : 0xFF666666))),
), ),
onTap: () { onTap: () {
if (onChange != null) {
onChange(index); onChange(index);
}
}, },
); );
}, },
...@@ -659,39 +636,39 @@ Widget _buildNewestWidget( ...@@ -659,39 +636,39 @@ Widget _buildNewestWidget(
); );
} }
String getHeaderTitle(TabVo tabVo ){ String? getHeaderTitle(TabVo tabVo ){
String title = ''; String? title = '';
if (tabVo.selected == null) { if (tabVo.selected == null) {
title = tabVo.text; title = tabVo.text;
} else if (tabVo.keyName == 'price_section') { } else if (tabVo.keyName == 'price_section') {
try { try {
if (tabVo.selected['price_section'] is Map) { if (tabVo.selected!['price_section'] is Map) {
Map<String, dynamic>.from(tabVo.selected['price_section']) Map<String, dynamic>.from(tabVo.selected!['price_section'])
.values .values
.forEach((ele) { .forEach((ele) {
if (title.isNotEmpty) { if (title!.isNotEmpty) {
title = title + '-'; title = title! + '-';
} }
title = title + '$ele'; title = title! + '$ele';
}); });
} }
} catch (e) { } catch (e) {
title = tabVo.text; title = tabVo.text;
} }
} else { } else {
title = '${tabVo.selected['text'] ?? tabVo.selected['name']}'; title = '${tabVo.selected!['text'] ?? tabVo.selected!['name']}';
} }
return title; return title;
} }
void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onChange,TabVo tabVo,void Function(int, TabVo) onNodeChange,int index}){ void onTapUpCallback({OverlayWidgetBuilder? callback,void Function(int, bool)? onChange,required TabVo tabVo,void Function(int?, TabVo)? onNodeChange,int? index}){
if (tabVo.type == '3') { if (tabVo.type == '3') {
callback(_buildNewestWidget( callback!(_buildNewestWidget(
structure: tabVo.structure ?? [], structure: tabVo.structure ?? [],
onChange: (v) { onChange: (v) {
if (tabVo.structure != null && tabVo.structure.length > v) { if (tabVo.structure != null && tabVo.structure!.length > v) {
callback(null); callback(null);
dynamic data = tabVo.structure[v]; dynamic data = tabVo.structure![v];
tabVo.selected = data; tabVo.selected = data;
if (onNodeChange != null) { if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
...@@ -700,10 +677,10 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC ...@@ -700,10 +677,10 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC
}, },
selected: tabVo.selected)); selected: tabVo.selected));
} else if (tabVo.type == '4') { } else if (tabVo.type == '4') {
callback(_buildPriceShowWidget( callback!(_buildPriceShowWidget(
structure: tabVo.structure[0], structure: tabVo.structure![0],
keyName: tabVo.keyName, keyName: tabVo.keyName,
onResultTap: (Map<String, dynamic> data) { onResultTap: (Map<String?, dynamic> data) {
tabVo.selected = data; tabVo.selected = data;
if (onNodeChange != null) { if (onNodeChange != null) {
onNodeChange(index, tabVo); onNodeChange(index, tabVo);
...@@ -720,7 +697,7 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC ...@@ -720,7 +697,7 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC
selected: tabVo.selected ?? {}, selected: tabVo.selected ?? {},
)); ));
} else if (tabVo.type == '5') { } else if (tabVo.type == '5') {
callback(_buildClassifyShowWidget( callback!(_buildClassifyShowWidget(
selected: tabVo.selected, selected: tabVo.selected,
structure: tabVo.structure, structure: tabVo.structure,
onResetTap: () { onResetTap: () {
...@@ -740,21 +717,21 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC ...@@ -740,21 +717,21 @@ void onTapUpCallback({OverlayWidgetBuilder callback,void Function(int, bool) onC
} }
} }
OverlayWidgetBuilder mCallback; OverlayWidgetBuilder? mCallback;
int _jindex = -1; int _jindex = -1;
/// ///
/// 分类 /// 分类
/// ///
Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs, Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs,
{GlobalKey anchorKey, {GlobalKey? anchorKey,
Map<String, dynamic> sellTab, Map<String, dynamic>? sellTab,
void Function(Map<String, dynamic>) onChangeSort, void Function(Map<String, dynamic>)? onChangeSort,
@required void Function(int, bool) onChange, required void Function(int, bool) onChange,
@required void Function(int, TabVo) onNodeChange}) { required void Function(int?, TabVo) onNodeChange}) {
Widget categoryWidget(int index,{Widget Function() onHeaderWidget}) { Widget categoryWidget(int index,{Widget Function()? onHeaderWidget}) {
TabVo tabVo = tabList[index]; TabVo tabVo = tabList[index];
String title = getHeaderTitle(tabVo); String? title = getHeaderTitle(tabVo);
return Expanded( return Expanded(
child: OtherWidget( child: OtherWidget(
onHeaderWidget:onHeaderWidget, onHeaderWidget:onHeaderWidget,
...@@ -781,19 +758,15 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs, ...@@ -781,19 +758,15 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs,
], ],
), ),
onCloseTap: () { onCloseTap: () {
if (onChange != null && _jindex != -1) { if (_jindex != -1) {
onChange(_jindex, false); onChange(_jindex, false);
} }
if (onChange != null) {
onChange(index, false); onChange(index, false);
}
_jindex = -1; _jindex = -1;
}, },
tapUpCallback: (OverlayWidgetBuilder callback) { tapUpCallback: (OverlayWidgetBuilder callback) {
mCallback = callback; mCallback = callback;
if (onChange != null) {
onChange(index, true); onChange(index, true);
}
onTapUpCallback(callback: mCallback,onChange:onChange,tabVo:tabVo,onNodeChange:onNodeChange,index:index); onTapUpCallback(callback: mCallback,onChange:onChange,tabVo:tabVo,onNodeChange:onNodeChange,index:index);
}, },
), ),
...@@ -833,9 +806,7 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs, ...@@ -833,9 +806,7 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs,
},onTap:(int jindex,TabVo tabVo){ },onTap:(int jindex,TabVo tabVo){
_jindex = jindex; _jindex = jindex;
if(mCallback == null){return;} if(mCallback == null){return;}
if (onChange != null) {
onChange(jindex, true); onChange(jindex, true);
}
onTapUpCallback(callback: mCallback,onChange:onChange,tabVo:tabVo,onNodeChange:onNodeChange,index:jindex); onTapUpCallback(callback: mCallback,onChange:onChange,tabVo:tabVo,onNodeChange:onNodeChange,index:jindex);
},); },);
}) })
...@@ -899,7 +870,7 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs, ...@@ -899,7 +870,7 @@ Widget buildCategoryTapWidget(List<TabVo> tabList, List<dynamic> sellingTabs,
/// ///
/// 当搜索的商品数据为空 /// 当搜索的商品数据为空
/// ///
Widget buildEmptyProductList({bool refresh = false, void Function() onResetTap}) { Widget buildEmptyProductList({bool refresh = false, void Function()? onResetTap}) {
Widget widget = Container( Widget widget = Container(
margin: EdgeInsets.only(top: 120.w), margin: EdgeInsets.only(top: 120.w),
child: Column( child: Column(
...@@ -924,9 +895,9 @@ Widget buildEmptyProductList({bool refresh = false, void Function() onResetTap}) ...@@ -924,9 +895,9 @@ Widget buildEmptyProductList({bool refresh = false, void Function() onResetTap})
class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate { class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {
_SliverTabBarDelegate({ _SliverTabBarDelegate({
@required this.minHeight, required this.minHeight,
@required this.maxHeight, required this.maxHeight,
@required this.child, required this.child,
}); });
final double minHeight; final double minHeight;
...@@ -957,16 +928,16 @@ class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate { ...@@ -957,16 +928,16 @@ class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {
/// 分类Widget /// 分类Widget
/// ///
class ClassifyShowWidget extends StatefulWidget { class ClassifyShowWidget extends StatefulWidget {
final Map<String, dynamic> selected; final Map<String?, dynamic>? selected;
final void Function(Map<String, dynamic>) onResultTap; final void Function(Map<String, dynamic>) onResultTap;
final void Function() onResetTap; final void Function() onResetTap;
final List<dynamic> structure; final List<dynamic>? structure;
const ClassifyShowWidget( const ClassifyShowWidget(
{Key key, {Key? key,
this.structure, this.structure,
@required this.onResultTap, required this.onResultTap,
@required this.onResetTap, required this.onResetTap,
this.selected}) this.selected})
: super(key: key); : super(key: key);
...@@ -975,7 +946,7 @@ class ClassifyShowWidget extends StatefulWidget { ...@@ -975,7 +946,7 @@ class ClassifyShowWidget extends StatefulWidget {
} }
class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
List<dynamic> structure, structureNode1; List<dynamic>? structure, structureNode1;
int childNode1 = 0, childNode2 = 0; int childNode1 = 0, childNode2 = 0;
...@@ -983,18 +954,18 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -983,18 +954,18 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
void initState() { void initState() {
this.structure = widget.structure; this.structure = widget.structure;
try { try {
if (widget.selected != null && widget.selected.isNotEmpty) { if (widget.selected != null && widget.selected!.isNotEmpty) {
String level = widget.selected['level']; String? level = widget.selected!['level'];
String parentId = widget.selected['parent_id']; String? parentId = widget.selected!['parent_id'];
String id = widget.selected['id']; String? id = widget.selected!['id'];
if (level == '1') { if (level == '1') {
childNode1 = this.structure.indexWhere((ele) => (ele['id'] == id)); childNode1 = this.structure!.indexWhere((ele) => (ele['id'] == id));
} else if (level == '2') { } else if (level == '2') {
childNode1 = childNode1 =
this.structure.indexWhere((ele) => (ele['id'] == parentId)); this.structure!.indexWhere((ele) => (ele['id'] == parentId));
if (this.structure[childNode1] != null) { if (this.structure![childNode1] != null) {
childNode2 = List<dynamic>.from(Map<String, dynamic>.from( childNode2 = List<dynamic>.from(Map<String, dynamic>.from(
this.structure[childNode1])['child']) this.structure![childNode1])['child'])
.indexWhere((ele) => (ele['id'] == id)); .indexWhere((ele) => (ele['id'] == id));
} }
} }
...@@ -1005,8 +976,8 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -1005,8 +976,8 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (structure[childNode1]['child'] != null) { if (structure![childNode1]['child'] != null) {
structureNode1 = List<dynamic>.from(structure[childNode1]['child']); structureNode1 = List<dynamic>.from(structure![childNode1]['child']);
} }
return Container( return Container(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
...@@ -1024,10 +995,10 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -1024,10 +995,10 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
width: 94.w, width: 94.w,
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
child: ListView.builder( child: ListView.builder(
itemCount: structure.length, itemCount: structure!.length,
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
dynamic dMap = structure[index]; dynamic dMap = structure![index];
return InkWell( return InkWell(
child: Container( child: Container(
padding: EdgeInsets.only(left: 12.w), padding: EdgeInsets.only(left: 12.w),
...@@ -1065,16 +1036,16 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -1065,16 +1036,16 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
); );
}), }),
), ),
if (structureNode1 != null && structureNode1.length > 0) if (structureNode1 != null && structureNode1!.length > 0)
Expanded( Expanded(
child: Container( child: Container(
color: Colors.white, color: Colors.white,
child: GridView.builder( child: GridView.builder(
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,crossAxisSpacing: 1.w,childAspectRatio: 3.3.w), gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,crossAxisSpacing: 1.w,childAspectRatio: 3.3.w),
itemCount: structureNode1.length, itemCount: structureNode1!.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
dynamic dMap = structureNode1[index]; dynamic dMap = structureNode1![index];
return InkWell( return InkWell(
child: Container( child: Container(
padding: EdgeInsets.only(left: 24.w), padding: EdgeInsets.only(left: 24.w),
...@@ -1114,9 +1085,7 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -1114,9 +1085,7 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
borderRadius: BorderRadius.circular(8.w)), borderRadius: BorderRadius.circular(8.w)),
), ),
onTap: () { onTap: () {
if (widget.onResetTap != null) {
widget.onResetTap(); widget.onResetTap();
}
}), }),
flex: 1, flex: 1,
...@@ -1131,18 +1100,16 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> { ...@@ -1131,18 +1100,16 @@ class _ClassifyShowWidgetState extends State<ClassifyShowWidget> {
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8),color: Color(0xFFFFBB00)), decoration: BoxDecoration(borderRadius: BorderRadius.circular(8),color: Color(0xFFFFBB00)),
), ),
onTap: () { onTap: () {
if (structureNode1 != null && structureNode1.isNotEmpty) { if (structureNode1 != null && structureNode1!.isNotEmpty) {
Map<String, dynamic> result = {}; Map<String, dynamic> result = {};
if (childNode2 == 0) { if (childNode2 == 0) {
result = Map<String, dynamic>.from(structure[childNode1]); result = Map<String, dynamic>.from(structure![childNode1]);
} else { } else {
result = Map<String, dynamic>.from(structureNode1[childNode2]); result = Map<String, dynamic>.from(structureNode1![childNode2]);
} }
result.remove('child'); result.remove('child');
if (widget.onResultTap != null) {
widget.onResultTap(result); widget.onResultTap(result);
} }
}
}), }),
flex: 3, flex: 3,
), ),
......
...@@ -5,20 +5,20 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -5,20 +5,20 @@ import 'package:common_module/utils/xapp_utils.dart';
typedef OverlayTapUpCallback = void Function(OverlayWidgetBuilder overlayBuilder); typedef OverlayTapUpCallback = void Function(OverlayWidgetBuilder overlayBuilder);
typedef OverlayWidgetBuilder = void Function(Widget overlayWidget); typedef OverlayWidgetBuilder = void Function(Widget? overlayWidget);
class OtherWidget extends StatefulWidget { class OtherWidget extends StatefulWidget {
final Widget child; final Widget child;
final OverlayTapUpCallback tapUpCallback; final OverlayTapUpCallback? tapUpCallback;
final GestureTapCallback onCloseTap; final GestureTapCallback? onCloseTap;
final Widget Function() onHeaderWidget; final Widget Function()? onHeaderWidget;
const OtherWidget({Key key, const OtherWidget({Key? key,
@required this.child, required this.child,
this.tapUpCallback, this.tapUpCallback,
this.onCloseTap, this.onCloseTap,
@required this.onHeaderWidget, required this.onHeaderWidget,
}) : super(key: key); }) : super(key: key);
@override @override
...@@ -28,21 +28,21 @@ class OtherWidget extends StatefulWidget { ...@@ -28,21 +28,21 @@ class OtherWidget extends StatefulWidget {
class _OtherWidgetState extends State<OtherWidget> { class _OtherWidgetState extends State<OtherWidget> {
GlobalKey globalKey = GlobalKey(); GlobalKey globalKey = GlobalKey();
OverlayEntry overlayEntry; OverlayEntry? overlayEntry;
void onCloseEntry({bool close}) { void onCloseEntry({bool? close}) {
if (overlayEntry != null) { if (overlayEntry != null) {
overlayEntry.remove(); overlayEntry!.remove();
overlayEntry = null; overlayEntry = null;
} }
if(widget.onCloseTap != null){ if(widget.onCloseTap != null){
widget.onCloseTap(); widget.onCloseTap!();
} }
} }
void showOverlayEntry({@required double height,@required double headerHeight ,@required Widget overlayWidget}) { void showOverlayEntry({required double height,required double headerHeight ,required Widget overlayWidget}) {
if(overlayEntry != null){ if(overlayEntry != null){
overlayEntry.remove(); overlayEntry!.remove();
overlayEntry = null; overlayEntry = null;
} }
overlayEntry = new OverlayEntry(maintainState: true,builder: (BuildContext context) { overlayEntry = new OverlayEntry(maintainState: true,builder: (BuildContext context) {
...@@ -50,7 +50,7 @@ class _OtherWidgetState extends State<OtherWidget> { ...@@ -50,7 +50,7 @@ class _OtherWidgetState extends State<OtherWidget> {
InkWell(child:Container(height:height ,color:Colors.transparent),onTap:onCloseEntry), InkWell(child:Container(height:height ,color:Colors.transparent),onTap:onCloseEntry),
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
child:widget.onHeaderWidget(),height:headerHeight, child:widget.onHeaderWidget!(),height:headerHeight,
color: Colors.transparent, color: Colors.transparent,
), ),
Container(child:overlayWidget,color:Color(0xFF000000).withAlpha(102)), Container(child:overlayWidget,color:Color(0xFF000000).withAlpha(102)),
...@@ -60,7 +60,7 @@ class _OtherWidgetState extends State<OtherWidget> { ...@@ -60,7 +60,7 @@ class _OtherWidgetState extends State<OtherWidget> {
), ),
],),color:Colors.transparent,)); ],),color:Colors.transparent,));
}); });
Overlay.of(context,rootOverlay: true).insert(overlayEntry); Overlay.of(context,rootOverlay: true)!.insert(overlayEntry!);
} }
@override @override
...@@ -80,12 +80,12 @@ class _OtherWidgetState extends State<OtherWidget> { ...@@ -80,12 +80,12 @@ class _OtherWidgetState extends State<OtherWidget> {
child: Container(child:widget.child,alignment:Alignment.center,), child: Container(child:widget.child,alignment:Alignment.center,),
onTap:(){ onTap:(){
if (overlayEntry != null) { if (overlayEntry != null) {
overlayEntry.remove(); overlayEntry!.remove();
overlayEntry = null; overlayEntry = null;
} }
RenderBox renderBox = context.findRenderObject(); RenderBox renderBox = context.findRenderObject() as RenderBox;
Offset offset = renderBox.localToGlobal(Offset.zero); Offset offset = renderBox.localToGlobal(Offset.zero);
widget.tapUpCallback((Widget overlayWidget){ widget.tapUpCallback!((Widget? overlayWidget){
if(overlayWidget == null){ if(overlayWidget == null){
onCloseEntry(close:true); onCloseEntry(close:true);
}else{ }else{
...@@ -105,16 +105,16 @@ class _OtherWidgetState extends State<OtherWidget> { ...@@ -105,16 +105,16 @@ class _OtherWidgetState extends State<OtherWidget> {
class OverlayEntryHeader extends StatefulWidget { class OverlayEntryHeader extends StatefulWidget {
final List<TabVo> tabList; final List<TabVo> tabList;
final String Function(TabVo) onHeaderTitle; final String? Function(TabVo)? onHeaderTitle;
final void Function(int,TabVo) onTap; final void Function(int,TabVo)? onTap;
const OverlayEntryHeader({ Key key,@required this.tabList,this.onHeaderTitle,this.onTap}) : super(key: key); const OverlayEntryHeader({ Key? key,required this.tabList,this.onHeaderTitle,this.onTap}) : super(key: key);
@override @override
_OverlayEntryHeaderState createState() => _OverlayEntryHeaderState(); _OverlayEntryHeaderState createState() => _OverlayEntryHeaderState();
} }
class _OverlayEntryHeaderState extends State<OverlayEntryHeader> { class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
List<TabVo> tabList; late List<TabVo> tabList;
@override @override
void initState() { void initState() {
...@@ -127,7 +127,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> { ...@@ -127,7 +127,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
return Row( return Row(
children:List.generate(tabList.length,(index){ children:List.generate(tabList.length,(index){
TabVo tabVo = tabList[index]; TabVo tabVo = tabList[index];
String title = widget.onHeaderTitle(tabVo); String? title = widget.onHeaderTitle!(tabVo);
return Expanded( return Expanded(
child:InkWell(child:Container( child:InkWell(child:Container(
alignment: Alignment.center, alignment: Alignment.center,
...@@ -146,7 +146,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> { ...@@ -146,7 +146,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
) )
],) ],)
),onTap:(){ ),onTap:(){
widget.onTap(index,tabVo); widget.onTap!(index,tabVo);
},), },),
flex:1, flex:1,
); );
......
...@@ -24,7 +24,7 @@ abstract class SearchWidgetDelegate { ...@@ -24,7 +24,7 @@ abstract class SearchWidgetDelegate {
/// ///
/// 设置页面isGrid /// 设置页面isGrid
/// ///
void setPageGrid({bool isGrid}); void setPageGrid({bool? isGrid});
} }
/// ///
...@@ -35,13 +35,13 @@ class SearchWidget extends StatefulWidget { ...@@ -35,13 +35,13 @@ class SearchWidget extends StatefulWidget {
final List<dynamic> priceCategory; final List<dynamic> priceCategory;
final Map<int, dynamic> platformIconMap; final Map<int, dynamic> platformIconMap;
final String keywords; final String keywords;
final void Function(Map<String, dynamic>) onGoodDetails; final void Function(Map<String, dynamic>)? onGoodDetails;
final void Function(SearchWidgetDelegate) onWidgetDelegate; final void Function(SearchWidgetDelegate)? onWidgetDelegate;
const SearchWidget( const SearchWidget(
{Key key, {Key? key,
@required this.priceCategory, required this.priceCategory,
@required this.keywords, required this.keywords,
@required this.platformIconMap, required this.platformIconMap,
this.isGrid = true, this.isGrid = true,
this.onGoodDetails, this.onGoodDetails,
this.onWidgetDelegate}) this.onWidgetDelegate})
...@@ -58,7 +58,7 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -58,7 +58,7 @@ class _SearchWidgetState extends State<SearchWidget>
IPriceActionDelegate { IPriceActionDelegate {
RefreshController _refreshController = RefreshController(); RefreshController _refreshController = RefreshController();
IPriceAction<PriceVo> _priceAction; IPriceAction<PriceVo>? _priceAction;
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
...@@ -66,11 +66,11 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -66,11 +66,11 @@ class _SearchWidgetState extends State<SearchWidget>
@override @override
void initState() { void initState() {
if (widget.onWidgetDelegate != null) { if (widget.onWidgetDelegate != null) {
widget.onWidgetDelegate(this); widget.onWidgetDelegate!(this);
} }
_priceAction = PriceAction(delegate: this); _priceAction = PriceAction(delegate: this);
_searchKeywords = widget.keywords; _searchKeywords = widget.keywords;
_priceAction.setPriceCategory( _priceAction!.setPriceCategory(
priceCategory: widget.priceCategory, priceCategory: widget.priceCategory,
keywords: _searchKeywords, keywords: _searchKeywords,
platformIconMap: widget.platformIconMap); platformIconMap: widget.platformIconMap);
...@@ -78,18 +78,18 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -78,18 +78,18 @@ class _SearchWidgetState extends State<SearchWidget>
} }
@override @override
void setPageGrid({bool isGrid}) { void setPageGrid({bool? isGrid}) {
_priceAction.getProductListVo()?.isGrid = isGrid; _priceAction!.getProductListVo().isGrid = isGrid;
_priceAction.getProductListVo()?.notifyListener(true); _priceAction!.getProductListVo().notifyListener(true);
} }
String _searchKeywords; String? _searchKeywords;
@override @override
void onKeywordsSearch(String keywords) { void onKeywordsSearch(String keywords) {
if (_searchKeywords != keywords) { if (_searchKeywords != keywords) {
_searchKeywords = keywords; _searchKeywords = keywords;
_priceAction.qryProductListEvent(keywords: keywords); _priceAction!.qryProductListEvent(keywords: keywords);
} }
} }
...@@ -98,7 +98,7 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -98,7 +98,7 @@ class _SearchWidgetState extends State<SearchWidget>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>( return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>(
dsAction: _priceAction, dsAction: _priceAction!,
builder: (BuildContext context, child) { builder: (BuildContext context, child) {
return Container( return Container(
color: Color(0xFFF5F5F5), color: Color(0xFFF5F5F5),
...@@ -115,12 +115,12 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -115,12 +115,12 @@ class _SearchWidgetState extends State<SearchWidget>
children: [ children: [
//Tab分类Widget //Tab分类Widget
buildSortHeader( buildSortHeader(
action: _priceAction, keywords: widget.keywords), action: _priceAction!, keywords: widget.keywords),
//商品列表 //商品列表
DSProvider.value( DSProvider.value(
vo: _priceAction.getProductListVo(), vo: _priceAction!.getProductListVo(),
builderWidget: (BuildContext context, builderWidget: (BuildContext context,
ProductListVo productListVo, Widget widget1) { ProductListVo productListVo, Widget? widget1) {
if (productListVo.productList.isEmpty) { if (productListVo.productList.isEmpty) {
if (productListVo.viewState == DSViewState.busy) { if (productListVo.viewState == DSViewState.busy) {
return SliverToBoxAdapter( return SliverToBoxAdapter(
...@@ -168,7 +168,7 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -168,7 +168,7 @@ class _SearchWidgetState extends State<SearchWidget>
'remark': entity.special 'remark': entity.special
}; };
if (widget.onGoodDetails != null) { if (widget.onGoodDetails != null) {
widget.onGoodDetails(goodDetails); widget.onGoodDetails!(goodDetails);
} }
})); }));
} else { } else {
...@@ -188,7 +188,7 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -188,7 +188,7 @@ class _SearchWidgetState extends State<SearchWidget>
'remark': entity.special 'remark': entity.special
}; };
if (widget.onGoodDetails != null) { if (widget.onGoodDetails != null) {
widget.onGoodDetails(goodDetails); widget.onGoodDetails!(goodDetails);
} }
}, },
)); ));
...@@ -201,22 +201,22 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -201,22 +201,22 @@ class _SearchWidgetState extends State<SearchWidget>
//Tab分类Widget //Tab分类Widget
Widget buildSortHeader( Widget buildSortHeader(
{@required IPriceAction<PriceVo> action, String keywords}) { {required IPriceAction<PriceVo> action, String? keywords}) {
return DSProvider.value( return DSProvider.value(
vo: action.getTabListVo(), vo: action.getTabListVo(),
builderWidget: builderWidget:
(BuildContext context, TabListVo tabListVo, Widget widget) { (BuildContext context, TabListVo tabListVo, Widget? widget) {
return buildTapWidget(context, tabList: tabListVo.tabList ?? [], return buildTapWidget(context, tabList: tabListVo.tabList,
onChange: (index, enable) { onChange: (index, enable) {
tabListVo?.tabList[index].open = enable; tabListVo.tabList[index].open = enable;
tabListVo.notifyListener(true); tabListVo.notifyListener(true);
}, onNodeChange: (int index, TabVo tabVo) { }, onNodeChange: (int? index, TabVo tabVo) {
tabVo.open = false; tabVo.open = false;
if (tabVo.selected != null && tabVo.selected['is_default'] == '1') { if (tabVo.selected != null && tabVo.selected!['is_default'] == '1') {
tabVo.selected = null; tabVo.selected = null;
} }
tabListVo.notifyListener(true); tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(keywords: keywords); _priceAction!.qryProductListEvent(keywords: keywords);
}); });
}); });
} }
...@@ -228,7 +228,7 @@ class _SearchWidgetState extends State<SearchWidget> ...@@ -228,7 +228,7 @@ class _SearchWidgetState extends State<SearchWidget>
} }
@override @override
void onloadFailed({String msg}) { void onloadFailed({String? msg}) {
_refreshController.loadFailed(); _refreshController.loadFailed();
_refreshController.refreshCompleted(resetFooterState: true); _refreshController.refreshCompleted(resetFooterState: true);
} }
......
import 'package:flutter/cupertino.dart';
import 'package:flutter_boost/flutter_boost.dart'; import 'package:flutter_boost/flutter_boost.dart';
/// ///
...@@ -14,14 +13,11 @@ class NavigateUtils { ...@@ -14,14 +13,11 @@ class NavigateUtils {
/// ///
/// ///
static Future<Map<dynamic, dynamic>> push({ static Future<Map<dynamic, dynamic>> push({
@required String path, required String path,
bool isNative = false, bool isNative = false,
bool needLogin = true, bool needLogin = true,
Map<String, dynamic> arguments = const {}, Map<String, dynamic> arguments = const {},
}) async { }) async {
if (arguments == null) {
arguments = {};
}
// 记录上一个页面的名称 // 记录上一个页面的名称
arguments['previousRouteName'] = _getPreviousRouteName(); arguments['previousRouteName'] = _getPreviousRouteName();
dynamic result = await BoostNavigator.instance.push( dynamic result = await BoostNavigator.instance.push(
...@@ -46,10 +42,10 @@ class NavigateUtils { ...@@ -46,10 +42,10 @@ class NavigateUtils {
/// [rootPath] 根路由路径 /// [rootPath] 根路由路径
/// ///
static popRoot({ static popRoot({
@required String rootPath, required String rootPath,
}) async { }) async {
await BoostNavigator.instance.pop().then((value) async { await BoostNavigator.instance.pop().then((value) async {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo(); PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
String pageName = pageInfo?.pageName ?? ''; String pageName = pageInfo?.pageName ?? '';
if (pageName.isNotEmpty && pageName != rootPath) { if (pageName.isNotEmpty && pageName != rootPath) {
await popRoot(rootPath: rootPath); await popRoot(rootPath: rootPath);
...@@ -58,8 +54,8 @@ class NavigateUtils { ...@@ -58,8 +54,8 @@ class NavigateUtils {
} }
// 获取下一个新页面的上一个页面名称(页面路径) // 获取下一个新页面的上一个页面名称(页面路径)
static String _getPreviousRouteName() { static String? _getPreviousRouteName() {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo(); PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
var boostPath = pageInfo?.pageName; var boostPath = pageInfo?.pageName;
return boostPath; return boostPath;
} }
......
...@@ -14,11 +14,11 @@ class TextSize { ...@@ -14,11 +14,11 @@ class TextSize {
/// ///
static Size calculateTextSize( static Size calculateTextSize(
BuildContext context, { BuildContext context, {
String value, String? value,
double fontSize, double? fontSize,
FontWeight fontWeight, FontWeight? fontWeight,
double maxWidth, required double maxWidth,
int maxLines, int? maxLines,
}) { }) {
TextPainter painter = TextPainter( TextPainter painter = TextPainter(
///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。 ///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。
......
...@@ -43,7 +43,7 @@ class TimeUtils { ...@@ -43,7 +43,7 @@ class TimeUtils {
return '0'; return '0';
} }
static String formatTime({String timestamp}) { static String formatTime({required String timestamp}) {
int time = int.parse(timestamp); int time = int.parse(timestamp);
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(time * 1000); DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(time * 1000);
DateTime endDate = new DateTime.now(); DateTime endDate = new DateTime.now();
......
...@@ -2,24 +2,24 @@ import 'package:flutter/material.dart'; ...@@ -2,24 +2,24 @@ import 'package:flutter/material.dart';
class ImageAnimationWidget extends StatelessWidget { class ImageAnimationWidget extends StatelessWidget {
final ValueNotifier<int> valueNotifier; final ValueNotifier<int>? valueNotifier;
final List<String> images; final List<String>? images;
final String package; final String? package;
final double width; final double? width;
final double height; final double? height;
const ImageAnimationWidget({ Key key,@required this.valueNotifier,@required this.images,this.package,this.width,this.height}) : super(key: key); const ImageAnimationWidget({ Key? key,required this.valueNotifier,required this.images,this.package,this.width,this.height}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: valueNotifier, valueListenable: valueNotifier!,
builder: (BuildContext context, int value, Widget child) { builder: (BuildContext context, int value, Widget? child) {
String image; String image;
if(value>=0 && value < images.length){ if(value>=0 && value < images!.length){
image = images[value]; image = images![value];
}else{ }else{
image = images[0]; image = images![0];
} }
return Image.asset(image,package:package,gaplessPlayback: true,width:width,height:height,); return Image.asset(image,package:package,gaplessPlayback: true,width:width,height:height,);
} }
......
...@@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; ...@@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
Widget buildAppSearchBar({ Widget buildAppSearchBar({
double height = 48, double height = 48,
Decoration decoration, Decoration? decoration,
EdgeInsetsGeometry margin, EdgeInsetsGeometry? margin,
EdgeInsetsGeometry padding, EdgeInsetsGeometry? padding,
Widget left, Widget? left,
Widget child, Widget? child,
Widget right, Widget? right,
}) { }) {
return PreferredSize( return PreferredSize(
child: SafeArea( child: SafeArea(
......
...@@ -7,8 +7,8 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -7,8 +7,8 @@ import 'package:common_module/utils/xapp_utils.dart';
class LoadingPage extends StatelessWidget { class LoadingPage extends StatelessWidget {
final String msg; final String msg;
final int length; final int length;
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
const LoadingPage({Key key, this.padding, this.msg = '1', this.length = 6}) const LoadingPage({Key? key, this.padding, this.msg = '1', this.length = 6})
: super(key: key); : super(key: key);
@override @override
...@@ -120,12 +120,12 @@ class LoadingPage extends StatelessWidget { ...@@ -120,12 +120,12 @@ class LoadingPage extends StatelessWidget {
/// [onReloadTap] 重新加载按钮 /// [onReloadTap] 重新加载按钮
/// ///
class FailedLoadPage extends StatelessWidget { class FailedLoadPage extends StatelessWidget {
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
final String errorMsg; final String errorMsg;
final void Function() onContactTap; final void Function()? onContactTap;
final void Function() onReloadTap; final void Function()? onReloadTap;
const FailedLoadPage( const FailedLoadPage(
{Key key, {Key? key,
this.margin, this.margin,
this.errorMsg = '加载失败,请刷新重试', this.errorMsg = '加载失败,请刷新重试',
this.onContactTap, this.onContactTap,
...@@ -195,10 +195,10 @@ class FailedLoadPage extends StatelessWidget { ...@@ -195,10 +195,10 @@ class FailedLoadPage extends StatelessWidget {
} }
Widget _buildButtonWidget( Widget _buildButtonWidget(
{@required String text, {required String text,
@required TextStyle style, required TextStyle style,
Decoration decoration, Decoration? decoration,
void Function() onTap}) { void Function()? onTap}) {
return InkWell( return InkWell(
child: Container( child: Container(
width: 164.w, width: 164.w,
......
...@@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; ...@@ -3,11 +3,11 @@ import 'package:flutter/material.dart';
class ImageWidget extends StatelessWidget { class ImageWidget extends StatelessWidget {
final String name; final String name;
final double width; final double? width;
final double height; final double? height;
final String package; final String package;
final BoxFit fit; final BoxFit? fit;
const ImageWidget({ Key key,@required this.name,this.width,this.height,this.package = 'price_module',this.fit}) : super(key: key); const ImageWidget({ Key? key,required this.name,this.width,this.height,this.package = 'price_module',this.fit}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -8,27 +8,27 @@ import 'package:flutter/material.dart'; ...@@ -8,27 +8,27 @@ import 'package:flutter/material.dart';
/// ///
class ItemProduct extends StatelessWidget { class ItemProduct extends StatelessWidget {
final Widget image; final Widget image;
final double height; final double? height;
final Decoration decoration; final Decoration? decoration;
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
final EdgeInsetsGeometry rightMargin; final EdgeInsetsGeometry? rightMargin;
final Widget title; final Widget title;
final Widget price; final Widget? price;
final Widget platform; final Widget? platform;
final void Function() onTap; final void Function()? onTap;
const ItemProduct({ const ItemProduct({
Key key, Key? key,
@required this.image, required this.image,
this.height, this.height,
this.decoration, this.decoration,
this.margin, this.margin,
this.rightMargin, this.rightMargin,
@required this.title, required this.title,
this.platform, this.platform,
this.price, this.price,
this.onTap this.onTap
...@@ -46,8 +46,8 @@ class ItemProduct extends StatelessWidget { ...@@ -46,8 +46,8 @@ class ItemProduct extends StatelessWidget {
image, image,
Expanded(child:Container(margin:rightMargin,child:Column(crossAxisAlignment: CrossAxisAlignment.start,children: [ Expanded(child:Container(margin:rightMargin,child:Column(crossAxisAlignment: CrossAxisAlignment.start,children: [
title, title,
Expanded(child:price,flex:1,), Expanded(child:price!,flex:1,),
platform platform!
],))) ],)))
], ],
), ),
......
...@@ -3,7 +3,7 @@ import 'package:price_module/widget/image/image_widget.dart'; ...@@ -3,7 +3,7 @@ import 'package:price_module/widget/image/image_widget.dart';
import 'package:common_module/utils/xapp_utils.dart'; import 'package:common_module/utils/xapp_utils.dart';
// //
Future<T> showPopBottomSheet<T>({BuildContext context,String pageName,Map<String,dynamic> extras,@required List<Map<String, dynamic>> items}){ Future<T?> showPopBottomSheet<T>({required BuildContext context,String? pageName,Map<String,dynamic>? extras,required List<Map<String, dynamic>> items}){
return showModalBottomSheet( return showModalBottomSheet(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -56,9 +56,9 @@ Future<T> showPopBottomSheet<T>({BuildContext context,String pageName,Map<String ...@@ -56,9 +56,9 @@ Future<T> showPopBottomSheet<T>({BuildContext context,String pageName,Map<String
Widget _buildShareWidget(BuildContext context, String key, Widget _buildShareWidget(BuildContext context, String key,
{@required String name, {required String name,
@required String title, required String title,
Map<String, dynamic> extras = const {}}) { Map<String, dynamic>? extras = const {}}) {
return Expanded( return Expanded(
child:InkWell( child:InkWell(
child: Column( child: Column(
......
...@@ -8,12 +8,12 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -8,12 +8,12 @@ import 'package:common_module/utils/xapp_utils.dart';
class PriceGridWidget extends StatelessWidget { class PriceGridWidget extends StatelessWidget {
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final bool shrinkWrap; final bool shrinkWrap;
final ScrollPhysics physics; final ScrollPhysics? physics;
final void Function(int) onItemTap; final void Function(int)? onItemTap;
final List<ProductItemEntity> list; final List<ProductItemEntity>? list;
final bool isHaoJia; final bool isHaoJia;
const PriceGridWidget( const PriceGridWidget(
{Key key, {Key? key,
this.padding = const EdgeInsets.all(0), this.padding = const EdgeInsets.all(0),
this.shrinkWrap = false, this.shrinkWrap = false,
this.physics, this.physics,
...@@ -31,15 +31,15 @@ class PriceGridWidget extends StatelessWidget { ...@@ -31,15 +31,15 @@ class PriceGridWidget extends StatelessWidget {
staggeredTileBuilder: (index) => StaggeredTile.fit(2), staggeredTileBuilder: (index) => StaggeredTile.fit(2),
mainAxisSpacing: 8.w, mainAxisSpacing: 8.w,
crossAxisSpacing: 9.w, crossAxisSpacing: 9.w,
itemCount: list.length, itemCount: list!.length,
itemBuilder: itemGridBuilder, itemBuilder: itemGridBuilder,
); );
} }
Widget itemGridBuilder(BuildContext context, int index) { Widget itemGridBuilder(BuildContext context, int index) {
ProductItemEntity vo = list[index]; ProductItemEntity vo = list![index];
return InkWell( return InkWell(
onTap: () => onItemTap(index), onTap: () => onItemTap!(index),
child: Container( child: Container(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
...@@ -56,7 +56,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -56,7 +56,7 @@ class PriceGridWidget extends StatelessWidget {
children: [ children: [
ClipRRect( ClipRRect(
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: vo.itemPic, imageUrl: vo.itemPic!,
placeholder: (BuildContext c, String s) { placeholder: (BuildContext c, String s) {
return Image.asset( return Image.asset(
'assets/images/placeholder_image.png', 'assets/images/placeholder_image.png',
...@@ -77,7 +77,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -77,7 +77,7 @@ class PriceGridWidget extends StatelessWidget {
width: 0.5.w, color: Color(0xFFE9E9E9)), width: 0.5.w, color: Color(0xFFE9E9E9)),
borderRadius: BorderRadius.all(Radius.circular(3.w))), borderRadius: BorderRadius.all(Radius.circular(3.w))),
child: Text( child: Text(
vo.platform, vo.platform!,
style: TextStyle( style: TextStyle(
color: Color(0xFF666666), color: Color(0xFF666666),
fontSize: 10.w, fontSize: 10.w,
...@@ -98,19 +98,19 @@ class PriceGridWidget extends StatelessWidget { ...@@ -98,19 +98,19 @@ class PriceGridWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
vo.itemTitle, vo.itemTitle!,
maxLines: 2, maxLines: 2,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 14.w), fontWeight: FontWeight.w600, fontSize: 14.w),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
vo.descriptionText.isEmpty vo.descriptionText!.isEmpty
? Container() ? Container()
: SizedBox(height: 4.w), : SizedBox(height: 4.w),
vo.descriptionText.isEmpty vo.descriptionText!.isEmpty
? Container() ? Container()
: Text( : Text(
vo.descriptionText, vo.descriptionText!,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
...@@ -129,7 +129,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -129,7 +129,7 @@ class PriceGridWidget extends StatelessWidget {
bottomRight: Radius.circular(8.w))), bottomRight: Radius.circular(8.w))),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 1.w, horizontal: 4.w), vertical: 1.w, horizontal: 4.w),
child: Text(vo.rebate, child: Text(vo.rebate!,
style: TextStyle( style: TextStyle(
color: Color(0xFFFF8000), color: Color(0xFFFF8000),
fontSize: 11.w, fontSize: 11.w,
...@@ -143,7 +143,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -143,7 +143,7 @@ class PriceGridWidget extends StatelessWidget {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: ListView.builder( child: ListView.builder(
itemCount: itemCount:
vo.tags.length >= 1 ? 1 : vo.tags.length, vo.tags!.length >= 1 ? 1 : vo.tags!.length,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Container( return Container(
...@@ -154,7 +154,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -154,7 +154,7 @@ class PriceGridWidget extends StatelessWidget {
Radius.circular(2.w))), Radius.circular(2.w))),
padding: padding:
EdgeInsets.symmetric(horizontal: 2.w), EdgeInsets.symmetric(horizontal: 2.w),
child: Text('${vo.tags[index]}', child: Text('${vo.tags![index]}',
style: TextStyle( style: TextStyle(
color: Color(0xFFB0B0B0), color: Color(0xFFB0B0B0),
fontSize: 11.w, fontSize: 11.w,
...@@ -169,7 +169,7 @@ class PriceGridWidget extends StatelessWidget { ...@@ -169,7 +169,7 @@ class PriceGridWidget extends StatelessWidget {
), ),
SizedBox(height: 4.w), SizedBox(height: 4.w),
Text( Text(
vo.special, vo.special!,
style: TextStyle( style: TextStyle(
color: Color(0xFFFF0400), color: Color(0xFFFF0400),
fontSize: 13.w, fontSize: 13.w,
...@@ -187,13 +187,13 @@ class PriceGridWidget extends StatelessWidget { ...@@ -187,13 +187,13 @@ class PriceGridWidget extends StatelessWidget {
class PriceListWidget extends StatelessWidget { class PriceListWidget extends StatelessWidget {
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final bool shrinkWrap; final bool shrinkWrap;
final ScrollPhysics physics; final ScrollPhysics? physics;
final void Function(ProductItemEntity, int) onItemTap; final void Function(ProductItemEntity, int)? onItemTap;
final bool scroll; final bool scroll;
final List<ProductItemEntity> list; final List<ProductItemEntity>? list;
final bool isHaoJia; final bool isHaoJia;
const PriceListWidget( const PriceListWidget(
{Key key, {Key? key,
this.padding = const EdgeInsets.all(0), this.padding = const EdgeInsets.all(0),
this.scroll = false, this.scroll = false,
this.shrinkWrap = false, this.shrinkWrap = false,
...@@ -208,16 +208,16 @@ class PriceListWidget extends StatelessWidget { ...@@ -208,16 +208,16 @@ class PriceListWidget extends StatelessWidget {
shrinkWrap: shrinkWrap, shrinkWrap: shrinkWrap,
physics: physics, physics: physics,
padding: padding, padding: padding,
itemCount: list.length, itemCount: list!.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
ProductItemEntity itemVo = list[index]; ProductItemEntity itemVo = list![index];
return _buildPriceItem( return _buildPriceItem(
index: index, index: index,
scroll: scroll, scroll: scroll,
itemEntity: itemVo, itemEntity: itemVo,
onTap: () { onTap: () {
if (onItemTap != null) { if (onItemTap != null) {
onItemTap(itemVo, index); onItemTap!(itemVo, index);
} }
}, },
); );
...@@ -226,10 +226,10 @@ class PriceListWidget extends StatelessWidget { ...@@ -226,10 +226,10 @@ class PriceListWidget extends StatelessWidget {
} }
Widget _buildPriceItem( Widget _buildPriceItem(
{int index, {required int index,
bool scroll, required bool scroll,
ProductItemEntity itemEntity, required ProductItemEntity itemEntity,
void Function() onTap}) { void Function()? onTap}) {
return InkWell( return InkWell(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
...@@ -261,8 +261,8 @@ class PriceListWidget extends StatelessWidget { ...@@ -261,8 +261,8 @@ class PriceListWidget extends StatelessWidget {
/// ///
/// 好价商品条目的标题等信息 /// 好价商品条目的标题等信息
/// ///
Widget _buildItemDetails({ProductItemEntity vo}) { Widget _buildItemDetails({required ProductItemEntity vo}) {
String descriptionText = vo.descriptionText; String? descriptionText = vo.descriptionText;
if (descriptionText != null && descriptionText.isNotEmpty) { if (descriptionText != null && descriptionText.isNotEmpty) {
descriptionText = descriptionText.replaceAll('\n', ''); descriptionText = descriptionText.replaceAll('\n', '');
descriptionText = descriptionText.replaceAll('\r', ''); descriptionText = descriptionText.replaceAll('\r', '');
...@@ -333,7 +333,7 @@ class PriceListWidget extends StatelessWidget { ...@@ -333,7 +333,7 @@ class PriceListWidget extends StatelessWidget {
child: Container( child: Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: ListView.builder( child: ListView.builder(
itemCount: vo.tags.length >= 1 ? 1 : vo.tags.length, itemCount: vo.tags!.length >= 1 ? 1 : vo.tags!.length,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Container( return Container(
...@@ -344,7 +344,7 @@ class PriceListWidget extends StatelessWidget { ...@@ -344,7 +344,7 @@ class PriceListWidget extends StatelessWidget {
BorderRadius.all(Radius.circular(2.w))), BorderRadius.all(Radius.circular(2.w))),
padding: EdgeInsets.symmetric(horizontal: 4.w), padding: EdgeInsets.symmetric(horizontal: 4.w),
alignment: Alignment.center, alignment: Alignment.center,
child: Text('${vo.tags[index]}', child: Text('${vo.tags![index]}',
style: TextStyle( style: TextStyle(
color: Color(0xFF666666), color: Color(0xFF666666),
fontSize: 11.w, fontSize: 11.w,
...@@ -377,7 +377,7 @@ class PriceListWidget extends StatelessWidget { ...@@ -377,7 +377,7 @@ class PriceListWidget extends StatelessWidget {
/// [scroll] 是否滚动 /// [scroll] 是否滚动
/// ///
Widget _buildLeftImage( Widget _buildLeftImage(
{@required String imageUrl, @required String source, bool scroll}) { {required String? imageUrl, required String source, required bool scroll}) {
return Container( return Container(
width: 104.w, width: 104.w,
height: 104.w, height: 104.w,
...@@ -390,7 +390,7 @@ class PriceListWidget extends StatelessWidget { ...@@ -390,7 +390,7 @@ class PriceListWidget extends StatelessWidget {
package: 'price_module', width: 104.w, height: 104.w) package: 'price_module', width: 104.w, height: 104.w)
: ClipRRect( : ClipRRect(
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: imageUrl, imageUrl: imageUrl!,
placeholder: (BuildContext c, String s) { placeholder: (BuildContext c, String s) {
return Image.asset( return Image.asset(
'assets/images/placeholder_image.png', 'assets/images/placeholder_image.png',
......
...@@ -2,11 +2,11 @@ import 'package:flutter/cupertino.dart'; ...@@ -2,11 +2,11 @@ import 'package:flutter/cupertino.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
class PullWidget extends StatelessWidget { class PullWidget extends StatelessWidget {
final Widget child; final Widget? child;
final VoidCallback onRefresh; final VoidCallback? onRefresh;
final VoidCallback onLoad; final VoidCallback? onLoad;
final RefreshController controller; final RefreshController? controller;
final ScrollController scrollController; final ScrollController? scrollController;
PullWidget( PullWidget(
{this.child, {this.child,
...@@ -21,7 +21,7 @@ class PullWidget extends StatelessWidget { ...@@ -21,7 +21,7 @@ class PullWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SmartRefresher( return SmartRefresher(
scrollController: scrollController, scrollController: scrollController,
controller: controller, controller: controller!,
enablePullDown: onRefresh != null, enablePullDown: onRefresh != null,
enablePullUp: onLoad != null, enablePullUp: onLoad != null,
onRefresh: onRefresh, onRefresh: onRefresh,
......
...@@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart'; ...@@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart';
import 'package:common_module/utils/xapp_utils.dart'; import 'package:common_module/utils/xapp_utils.dart';
Widget buildTabbarButton({@required String title,@required String tabBarType,TabbarController controller}){ Widget buildTabbarButton({required String title,required String tabBarType,TabbarController? controller}){
return Container(child:Column(mainAxisAlignment:MainAxisAlignment.center,children: [ return Container(child:Column(mainAxisAlignment:MainAxisAlignment.center,children: [
Container( Container(
width:24.w, width:24.w,
...@@ -24,7 +24,7 @@ Widget buildTabbarButton({@required String title,@required String tabBarType,Tab ...@@ -24,7 +24,7 @@ Widget buildTabbarButton({@required String title,@required String tabBarType,Tab
class TabbarWidget extends StatefulWidget { class TabbarWidget extends StatefulWidget {
final Function(TabbarController) controller; final Function(TabbarController) controller;
final String tabBarType; final String tabBarType;
const TabbarWidget({ Key key,@required this.controller,@required this.tabBarType}) : super(key: key); const TabbarWidget({ Key? key,required this.controller,required this.tabBarType}) : super(key: key);
@override @override
_TabbarWidgetState createState() => _TabbarWidgetState(); _TabbarWidgetState createState() => _TabbarWidgetState();
...@@ -32,8 +32,8 @@ class TabbarWidget extends StatefulWidget { ...@@ -32,8 +32,8 @@ class TabbarWidget extends StatefulWidget {
class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,SingleTickerProviderStateMixin{ class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,SingleTickerProviderStateMixin{
Animation<double> _animation; late Animation<double> _animation;
AnimationController _controller; late AnimationController _controller;
int interval = 200; int interval = 200;
List<Image> images=[]; List<Image> images=[];
...@@ -78,7 +78,7 @@ class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,Singl ...@@ -78,7 +78,7 @@ class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,Singl
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: index, valueListenable: index,
builder: (BuildContext context, int value, Widget child) { builder: (BuildContext context, int value, Widget? child) {
return images[value]; return images[value];
} }
); );
......
...@@ -6,7 +6,7 @@ homepage: / ...@@ -6,7 +6,7 @@ homepage: /
publish_to: none publish_to: none
environment: environment:
sdk: ">=2.8.0 <3.0.0" sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.17.0 <2.0.0" flutter: ">=1.17.0 <2.0.0"
dependencies: dependencies:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment