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
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.
```
\ No newline at end of file
import 'package:flutter/foundation.dart';
class NotifyEventType {
NotifyEventEnum eventType;
NotifyEventType({@required this.eventType});
NotifyEventType({required this.eventType});
}
enum NotifyEventEnum {
......
import 'package:flutter/material.dart';
abstract class IDSAction<VM> {
VM vm;
VM? vm;
void initState();
......
......@@ -8,12 +8,12 @@ class DSProvider<VO extends IDSModel> extends ChangeNotifierProvider<VO> {
final Widget Function(
BuildContext context,
VO value,
Widget child,
Widget? child,
) builderWidget;
DSProvider.value({
@required this.vo,
@required this.builderWidget,
required this.vo,
required this.builderWidget,
}) : super.value(
value: vo,
child: Consumer<VO>(
......
......@@ -7,19 +7,19 @@ import 'package:provider/provider.dart';
class DSProviderWidget<VM extends IDSModel, T extends IDSAction<VM>> extends StatefulWidget {
final T dsAction;
final Widget child;
final Widget Function(BuildContext context,Widget child) builder;
final Widget? child;
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
_DSProviderWidgetState<VM,T> createState() => _DSProviderWidgetState<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
void initState() {
......@@ -30,8 +30,8 @@ class _DSProviderWidgetState<VM extends IDSModel,T extends IDSAction<VM>> extend
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<VM>.value(
value: action.vm,
return ChangeNotifierProvider<VM?>.value(
value: action!.vm,
child: Consumer<VM>(
builder:(context,vm,child){
action?.initBuilder(context);
......
class DSNetException implements Exception {
final String message;
final int code;
final String? message;
final int? code;
@pragma("vm:entry-point")
const DSNetException({this.message = "", this.code});
String toString() {
......
This diff is collapsed.
......@@ -28,15 +28,15 @@ abstract class IPriceDiscountAction<PriceDiscountVo>
PriceDiscountVo get getVo;
}
class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo?> {
PriceRepository _priceRepository = PriceRepository.get();
Map<int, dynamic> _platformIconMap;
IPriceDiscountDelegate _discountDelegate;
Map<String, dynamic> _pageParam;
Map<int, dynamic>? _platformIconMap;
IPriceDiscountDelegate? _discountDelegate;
Map<String, dynamic>? _pageParam;
PriceDiscountAction({
IPriceDiscountDelegate delegate,
Map<String, dynamic> pageParam,
IPriceDiscountDelegate? delegate,
Map<String, dynamic>? pageParam,
}) {
this._pageParam = pageParam;
_discountDelegate = delegate;
......@@ -61,7 +61,7 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
pagesize: 10,
isRefresh: true,
);
this.vm.notifyListener();
this.vm!.notifyListener();
}
@override
......@@ -85,12 +85,12 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
}) {
currentPage = page;
if (isFirst) {
this.vm.viewState = DSViewState.busy;
this.vm!.viewState = DSViewState.busy;
}
_priceRepository
.getSellingRecommends(
keywords: _pageParam['keywords'],
excludeId: _pageParam['excludeId'],
keywords: _pageParam!['keywords'],
excludeId: _pageParam!['excludeId'],
page: page,
pagesize: pagesize,
)
......@@ -99,37 +99,37 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
List<ProductItemEntity> productEntitys = value.data;
productEntitys.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime);
ele.platform = _getPlatformName(int.parse(ele.platform));
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = _getPlatformName(int.parse(ele.platform!));
});
if (isLoad) {
if (this.vm.productEntitys == null) {
this.vm.productEntitys = List<ProductItemEntity>.empty(growable: true);
if (this.vm!.productEntitys == null) {
this.vm!.productEntitys = List<ProductItemEntity>.empty(growable: true);
}
this.vm.productEntitys.addAll(productEntitys);
this.vm!.productEntitys!.addAll(productEntitys);
} else {
this.vm.productEntitys = productEntitys;
if (this.vm.productEntitys.isEmpty) {
this.vm.viewState = DSViewState.empty;
this.vm!.productEntitys = productEntitys;
if (this.vm!.productEntitys!.isEmpty) {
this.vm!.viewState = DSViewState.empty;
} else {
this.vm.viewState = DSViewState.idle;
this.vm!.viewState = DSViewState.idle;
}
}
}
if (isLoad) {
_discountDelegate.onLoadComplete(isLoading: true);
_discountDelegate!.onLoadComplete(isLoading: true);
} else if (isRefresh) {
_discountDelegate.onLoadComplete(isLoading: false);
_discountDelegate!.onLoadComplete(isLoading: false);
}
}).catchError((error) {
this.vm.viewState = DSViewState.error;
this.vm!.viewState = DSViewState.error;
if (isLoad) {
_discountDelegate.onloadFailed(isLoading: true);
_discountDelegate!.onloadFailed(isLoading: true);
} else if (isRefresh) {
_discountDelegate.onloadFailed(isLoading: false);
_discountDelegate!.onloadFailed(isLoading: false);
}
}).whenComplete(() {
this.vm.notifyListener();
this.vm!.notifyListener();
});
}
......@@ -138,16 +138,16 @@ class PriceDiscountAction extends IPriceDiscountAction<PriceDiscountVo> {
/// [platform] 平台id
///
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>.from(_platformIconMap[platform]);
Map<String, dynamic>.from(_platformIconMap![platform]);
return platformMap['name'] ?? '';
}
return '';
}
@override
PriceDiscountVo get getVo => this.vm;
PriceDiscountVo? get getVo => this.vm;
}
///
......@@ -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> {
///
/// 代理设置
///
IPriceAction({IPriceActionDelegate delegate, bool isGrid});
IPriceAction({IPriceActionDelegate? delegate, bool? isGrid});
///
/// 设置分类参数
///
void setPriceCategory(
{List<dynamic> sellingTabList,
List<dynamic> priceCategory,
Map<int, dynamic> platformIconMap,
String keywords});
{List<dynamic>? sellingTabList,
List<dynamic>? priceCategory,
Map<int, dynamic>? platformIconMap,
String? keywords});
///
/// 获取分类Tab
......@@ -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> {
class PriceAction extends IPriceAction<PriceVo> {
PriceRepository _repository = PriceRepository.get();
Map<int, dynamic> platformIconMap;
String keywords;
bool isGrid = false;
IPriceActionDelegate delegate;
Map<int, dynamic>? platformIconMap;
String? keywords;
bool? isGrid = false;
IPriceActionDelegate? delegate;
PriceAction({this.delegate, this.isGrid}) : super(delegate: delegate);
@override
......@@ -82,14 +82,14 @@ class PriceAction extends IPriceAction<PriceVo> {
}
@override
List<dynamic> get sellingTabs => this.vm.sellingTabs ?? [];
List<dynamic> get sellingTabs => this.vm!.sellingTabs ?? [];
@override
void setPriceCategory(
{List<dynamic> sellingTabList,
List<dynamic> priceCategory,
Map<int, dynamic> platformIconMap,
String keywords}) {
{List<dynamic>? sellingTabList,
List<dynamic>? priceCategory,
Map<int, dynamic>? platformIconMap,
String? keywords}) {
this.platformIconMap = platformIconMap;
this.page = 1;
if (keywords != null && keywords.isNotEmpty) {
......@@ -99,16 +99,16 @@ class PriceAction extends IPriceAction<PriceVo> {
if (this.vm == null) {
this.vm = PriceVo();
}
if (this.vm.tabListVo == null) {
this.vm.tabListVo = TabListVo();
if (this.vm!.tabListVo == null) {
this.vm!.tabListVo = TabListVo();
}
this.vm.sellingTabs = sellingTabList;
this.vm!.sellingTabs = sellingTabList;
dynamic data = this
.vm
.vm!
.sellingTabs
?.singleWhere((ele) => ele['is_default'] == '1', orElse: () => null);
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) {
List<TabVo> tabList = List<TabVo>.empty(growable: true);
......@@ -117,22 +117,22 @@ class PriceAction extends IPriceAction<PriceVo> {
tabList.add(TabVo.fromJson(
'${categoryMap['type']}', Map<String, dynamic>.from(ele)));
});
TabListVo tabListVo = this.vm.tabListVo;
TabListVo tabListVo = this.vm!.tabListVo!;
tabListVo.tabList = tabList;
this.vm.tabListVo = tabListVo;
this.vm!.tabListVo = tabListVo;
}
TabListVo tabListVo = this.vm.tabListVo;
String categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab['id'] != null) {
categoryId = "${tabListVo.sellTab['id']}";
TabListVo tabListVo = this.vm!.tabListVo!;
String? categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab!['id'] != null) {
categoryId = "${tabListVo.sellTab!['id']}";
}
_qryProductList(keywords: keywords, categoryId: categoryId);
}
@override
TabListVo getTabListVo() {
return this.vm.tabListVo ?? TabListVo();
return this.vm!.tabListVo ?? TabListVo();
}
@override
......@@ -145,12 +145,12 @@ class PriceAction extends IPriceAction<PriceVo> {
///
@override
void resetProductList() async {
for (TabVo item in this.vm.tabListVo?.tabList ?? []) {
for (TabVo item in this.vm!.tabListVo?.tabList ?? []) {
item.selected = null;
item.open = false;
}
this.vm.tabListVo?.sellTab = null;
this.vm.tabListVo?.notifyListener(true);
this.vm!.tabListVo?.sellTab = null;
this.vm!.tabListVo?.notifyListener(true);
_qryProductList(keywords: this.keywords);
}
......@@ -158,12 +158,12 @@ class PriceAction extends IPriceAction<PriceVo> {
/// 过滤筛选条件
///
@override
void qryProductListEvent({String keywords, int page = 1}) async {
void qryProductListEvent({String? keywords, int? page = 1}) async {
if (keywords != null) {
this.keywords = keywords;
}
List<dynamic> filters;
this.vm.tabListVo?.tabList?.forEach((ele) {
List<dynamic>? filters;
this.vm!.tabListVo?.tabList.forEach((ele) {
if (filters == null) {
filters = List<dynamic>.empty(growable: true);
}
......@@ -172,39 +172,39 @@ class PriceAction extends IPriceAction<PriceVo> {
if (ele.keyName == 'category') {
data = {
'key_name': ele.keyName,
'key_value': '${ele.selected['id']}'
'key_value': '${ele.selected!['id']}'
};
} else if (ele.keyName == 'price_section') {
data = {
'key_name': ele.keyName,
'key_value': ele.selected['price_section']
'key_value': ele.selected!['price_section']
};
} else {
data = {
'key_name': ele.keyName,
'key_value': '${ele.selected['type']}'
'key_value': '${ele.selected!['type']}'
};
}
if (data != null && data.isNotEmpty) {
filters.add(data);
if (data.isNotEmpty) {
filters!.add(data);
}
}
});
TabListVo tabListVo = this.vm.tabListVo;
String categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab['id'] != null) {
categoryId = "${tabListVo.sellTab['id']}";
TabListVo tabListVo = this.vm!.tabListVo!;
String? categoryId;
if (tabListVo.sellTab != null && tabListVo.sellTab!['id'] != null) {
categoryId = "${tabListVo.sellTab!['id']}";
}
_qryProductList(
keywords: this.keywords,
filters: filters,
page: page,
page: page!,
categoryId: categoryId);
}
@override
void closeTab() {
TabListVo tabListVo = this.vm.tabListVo;
TabListVo tabListVo = this.vm!.tabListVo!;
tabListVo.tabList.forEach((ele) {
ele.open = false;
});
......@@ -212,9 +212,9 @@ class PriceAction extends IPriceAction<PriceVo> {
}
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>.from(platformIconMap[platform]);
Map<String, dynamic>.from(platformIconMap![platform]);
return platformMap['name'] ?? '';
}
return '';
......@@ -223,10 +223,10 @@ class PriceAction extends IPriceAction<PriceVo> {
void _qryProductList(
{int page = 1,
int pagesize = 10,
String keywords,
String categoryId,
List<dynamic> filters}) async {
this.page = page ?? 1;
String? keywords,
String? categoryId,
List<dynamic>? filters}) async {
this.page = page;
await _repository
.qryProductList(
page: page,
......@@ -242,8 +242,8 @@ class PriceAction extends IPriceAction<PriceVo> {
if (value.isSuccess) {
productList = value.data;
productList.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime);
ele.platform = getPlatformName(int.parse(ele.platform));
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = getPlatformName(int.parse(ele.platform!));
});
}
this.vm?.productListVo?.productList = productList;
......@@ -252,11 +252,10 @@ class PriceAction extends IPriceAction<PriceVo> {
if (value.isSuccess) {
productList = value.data;
productList.forEach((ele) {
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime);
ele.platform = getPlatformName(int.parse(ele.platform));
ele.releaseTime = TimeUtils.formatTime(timestamp: ele.releaseTime!);
ele.platform = getPlatformName(int.parse(ele.platform!));
});
this.vm?.productListVo?.productList?.addAll(productList);
this.vm?.productListVo?.productList.addAll(productList);
}
}
delegate?.onLoadComplete();
......@@ -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';
import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
class PriceDetailsVo extends IDSModel {
String productId;
List<String> itemPic;
String itemTitle;
String subTitle;
String description;
String status;
String? productId;
List<String?>? itemPic;
String? itemTitle;
String? subTitle;
String? description;
String? status;
//商品的ItemId
String itemId;
String? itemId;
//平台Id
String platform;
String? platform;
//平台名称
String platformText;
String? platformText;
//喜欢次数
String likeTimes;
String? likeTimes;
//收藏次数
String collegeTimes;
String? collegeTimes;
//是否喜欢和收藏
bool isLike = false;
bool isFavorites = false;
//Button按钮的文字
String buttonText;
String price;
String endPrice;
String? buttonText;
String? price;
String? endPrice;
//发布时间
String releaseTime;
String checkText;
String? releaseTime;
String? checkText;
//分享文字和分享URL
String shareUrl;
String shareMessage;
String? shareUrl;
String? shareMessage;
//优惠卷
List<Coupon> coupons = [];
//举报
List<ReportModel> reports = [];
List<ReportModel>? reports = [];
//优惠卷过期描述
String couponText;
String? couponText;
String isOverdue;
String shopTitle;
String rebate;
List<dynamic> collectOrders;
Map<String, dynamic> newItemInfo;
String? isOverdue;
String? shopTitle;
String? rebate;
List<dynamic>? collectOrders;
Map<String, dynamic>? newItemInfo;
//商品推荐相关信息
List<ProductItemEntity> productEntitys;
List<ProductItemEntity>? productEntitys;
PriceDetailsVo({
this.productId,
......@@ -79,15 +79,15 @@ class PriceDetailsVo extends IDSModel {
}
class Coupon {
String url;
String name;
String status;
String? url;
String? name;
String? status;
Coupon({this.url, this.name, this.status});
}
class ReportModel {
String value;
String text;
List<ReportModel> sub = [];
String? value;
String? text;
List<ReportModel>? sub = [];
ReportModel({this.value, this.text, this.sub});
}
......@@ -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';
class PriceVo extends IDSModel {
// 商品列表
ProductListVo productListVo;
ProductListVo? productListVo;
//筛选Tab
TabListVo tabListVo;
TabListVo? tabListVo;
// 快捷分类列表
List<dynamic> sellingTabs;
List<dynamic>? sellingTabs;
PriceVo({this.productListVo, this.tabListVo, this.sellingTabs});
}
......@@ -17,19 +17,19 @@ class TabListVo extends IDSModel {
//分类
List<TabVo> tabList = [];
//快捷分类
Map<String, dynamic> sellTab;
Map<String, dynamic>? sellTab;
TabListVo({this.tabList = const [], this.sellTab});
}
class TabVo extends IDSModel {
String type;
String text;
String keyName;
String? type;
String? text;
String? keyName;
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});
......@@ -45,7 +45,7 @@ class TabVo extends IDSModel {
}
class ProductListVo extends IDSModel {
bool isGrid = false;
bool? isGrid = false;
List<ProductItemEntity> productList = [];
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/page/model/details/index.dart';
import 'package:price_module/utils/time_utils.dart';
......@@ -15,15 +14,15 @@ class PriceDetailsService {
/// 查询商品详情
/// [productId] 查询的商品Id
///
Future<PriceDetailsVo> qryProductDetails({@required String productId}) async {
Future<PriceDetailsVo> qryProductDetails({required String productId}) async {
return await _priceRepository
.qryProductDetails(id: productId)
.asStream()
.map((event) {
PriceDetailsVo detailsVo;
PriceDetailsVo? detailsVo;
if (event.isSuccess) {
detailsVo = PriceDetailsVo();
ProductDetailsEntity entity = event.data;
ProductDetailsEntity entity = event.data!;
detailsVo.viewState = DSViewState.idle;
detailsVo.likeTimes = entity.likeTimes;
detailsVo.collegeTimes = entity.collegeTimes;
......@@ -40,18 +39,16 @@ class PriceDetailsService {
detailsVo.isFavorites = entity.isCollect == '1';
detailsVo.shareMessage = entity.shareMessage ?? '';
detailsVo.shareUrl = entity.shareUrl ?? '';
if (entity.releaseTime != null && entity.releaseTime.length > 0) {
if (entity.releaseTime != null && entity.releaseTime!.length > 0) {
detailsVo.releaseTime =
TimeUtils.formatTime(timestamp: entity.releaseTime);
TimeUtils.formatTime(timestamp: entity.releaseTime!);
}
detailsVo.checkText = entity.checkText ?? '';
detailsVo.endPrice = entity.endPrice;
detailsVo.price = entity.price;
detailsVo.coupons =
List.generate(entity.couponInfos?.length, (index) {
CouponInfo info = entity.couponInfos[index];
return Coupon(
name: info.couponName, url: info.url, status: info.status);
detailsVo.coupons = List.generate(entity.couponInfos?.length??0, (index) {
CouponInfo info = entity.couponInfos![index];
return Coupon(name: info.couponName, url: info.url, status: info.status);
});
detailsVo.isOverdue = entity.isOverdue;
detailsVo.shopTitle = entity.shopTitle;
......@@ -75,8 +72,8 @@ class PriceDetailsService {
/// [pagesize] 当前页显示的大小
///
Future<DSResponseList<ProductItemEntity>> getSellingRecommends({
String keywords,
String excludeId,
String? keywords,
String? excludeId,
int page = 1,
int pagesize = 10,
}) async {
......@@ -94,7 +91,7 @@ class PriceDetailsService {
/// [report_type] 举报的商品类型
///
Future<dynamic> report(
{@required String id, @required String reportType}) async {
{required String id, required String reportType}) async {
return await _priceRepository
.report(id: id, reportType: reportType)
.asStream()
......@@ -111,8 +108,8 @@ class PriceDetailsService {
/// [platform] 平台
///
Future<dynamic> userLike(
{@required String markId,
@required String platform,
{required String markId,
required String platform,
String type = '2',
String status = '1'}) async {
return await _priceRepository
......@@ -128,8 +125,8 @@ class PriceDetailsService {
/// 用户收藏
///
Future<dynamic> userCollect(
{@required String itemId,
@required String platform,
{required String itemId,
required String platform,
String type = '2',
String status = '1'}) async {
return await _priceRepository
......@@ -148,8 +145,8 @@ class PriceDetailsService {
/// [type] 转链类型 好价传6 默认为5
///
Future<DSResponseObject<TurnChainEntity>> turnChainForItemId(
{@required String itemId,
@required String platform,
{required String itemId,
required String platform,
String type = '6'}) async {
return await _priceRepository
.turnChainForItemId(itemId: itemId, platform: platform, type: type)
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ import 'package:common_module/utils/xapp_utils.dart';
///
class PriceDiscountPage extends StatefulWidget {
final Map<String, dynamic> pageParam;
const PriceDiscountPage({Key key, @required this.pageParam})
const PriceDiscountPage({Key? key, required this.pageParam})
: super(key: key);
@override
_PriceDiscountPageState createState() => _PriceDiscountPageState();
......@@ -27,10 +27,10 @@ class PriceDiscountPage extends StatefulWidget {
class _PriceDiscountPageState extends State<PriceDiscountPage>
with IPriceDiscountDelegate {
IPriceDiscountAction _discountAction;
IPriceDiscountAction? _discountAction;
bool _isAudituser = false;
List<dynamic> _sellReportList;
bool? _isAudituser = false;
List<dynamic>? _sellReportList;
@override
void initState() {
_isAudituser = widget.pageParam['isAudituser'];
......@@ -49,30 +49,30 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
Widget build(BuildContext context) {
return DSProviderWidget<PriceDiscountVo,
IPriceDiscountAction<PriceDiscountVo>>(
dsAction: _discountAction,
builder: (BuildContext context, Widget child) {
dsAction: _discountAction as IPriceDiscountAction<PriceDiscountVo>,
builder: (BuildContext context, Widget? child) {
return Scaffold(
appBar: buildAppBar(),
body: _buildBody1(vo: _discountAction.getVo),
appBar: buildAppBar() as PreferredSizeWidget,
body: _buildBody1(vo: _discountAction!.getVo),
);
},
);
}
Widget _buildBody1({PriceDiscountVo vo}) {
Widget _buildBody1({required PriceDiscountVo vo}) {
return PullWidget(
controller: _refreshController,
child: Container(child: _buildBody(vo: vo)),
onRefresh: () {
_discountAction.reloadData();
_discountAction!.reloadData();
},
onLoad: () {
_discountAction.onLoad();
_discountAction!.onLoad();
},
);
}
Widget _buildBody({PriceDiscountVo vo}) {
Widget _buildBody({required PriceDiscountVo vo}) {
if (vo.viewState == DSViewState.busy) {
return LoadingPage(
padding: EdgeInsets.all(13.w),
......@@ -86,7 +86,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
vo.viewState == DSViewState.empty ? '未发现数据,请刷新重试' : '加载失败,请刷新重试',
onReloadTap: () {
//重新加载数据
_discountAction.reloadData();
_discountAction!.reloadData();
},
);
}
......@@ -127,7 +127,7 @@ class _PriceDiscountPageState extends State<PriceDiscountPage>
}
@override
void onloadFailed({bool isLoading = true, String msg}) {
void onloadFailed({bool isLoading = true, String? msg}) {
if (isLoading) {
_refreshController.loadFailed();
} else {
......
......@@ -20,7 +20,7 @@ abstract class PricePageDelegate {
/// [type] 1、白菜专区 2、爆单页面 3、搜索页面 4、商品详情
/// [data] 当[type]等于4时,[data]为传递的数据
///
void onRouteTap({@required String type, Map<String, dynamic> data});
void onRouteTap({required String type, Map<String, dynamic>? data});
///
/// 获取好价的快捷Tab
......@@ -29,11 +29,11 @@ abstract class PricePageDelegate {
}
class PricePage extends StatefulWidget {
final PricePageDelegate pageDelegate;
final List<dynamic> priceCategory;
final Map<int, dynamic> platformIconMap;
final PricePageDelegate? pageDelegate;
final List<dynamic>? priceCategory;
final Map<int, dynamic>? platformIconMap;
const PricePage(
{Key key, this.pageDelegate, this.platformIconMap, this.priceCategory})
{Key? key, this.pageDelegate, this.platformIconMap, this.priceCategory})
: super(key: key);
@override
_PricePageState createState() => _PricePageState();
......@@ -41,14 +41,14 @@ class PricePage extends StatefulWidget {
class _PricePageState extends BaseUmengPageViewItemState<PricePage>
with IPriceActionDelegate {
IPriceAction<PriceVo> _priceAction;
IPriceAction<PriceVo>? _priceAction;
@override
void initState() {
super.initState();
_priceAction = PriceAction(delegate: this);
_priceAction.setPriceCategory(
sellingTabList: widget.pageDelegate.sellingTabList,
_priceAction!.setPriceCategory(
sellingTabList: widget.pageDelegate!.sellingTabList,
priceCategory: widget.priceCategory,
platformIconMap: widget.platformIconMap);
}
......@@ -57,7 +57,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
Widget build(BuildContext context) {
super.build(context);
return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>(
dsAction: _priceAction,
dsAction: _priceAction!,
builder: (BuildContext context, child) {
return Scaffold(
backgroundColor: Color(0xFFF5F5F5),
......@@ -65,12 +65,12 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
onSearchTap: () {
widget.pageDelegate?.onRouteTap(type: '3');
},
isGrid: _priceAction.vm?.productListVo?.isGrid ?? false,
isGrid: _priceAction!.vm?.productListVo?.isGrid ?? false,
onLayoutTap: (bool isGrid) async {
_priceAction.vm?.productListVo?.isGrid = isGrid ?? true;
_priceAction.vm?.notifyListener(true);
}),
body: _buildBody(action: _priceAction),
_priceAction!.vm?.productListVo?.isGrid = isGrid;
_priceAction!.vm?.notifyListener(true);
}) as PreferredSizeWidget?,
body: _buildBody(action: _priceAction!),
);
});
}
......@@ -81,7 +81,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
ValueNotifier<double> backColorListenable = ValueNotifier<double>(136.0.w);
GlobalKey anchorKey = GlobalKey();
Widget _buildBody({IPriceAction<PriceVo> action}) {
Widget _buildBody({required IPriceAction<PriceVo> action}) {
return Stack(
children: [
// 底部设置一个背景跟随滑动
......@@ -105,33 +105,33 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
DSProvider.value(
vo: action.getTabListVo(),
builderWidget: (BuildContext context, TabListVo tabListVo,
Widget child) {
Widget? child) {
return buildCategoryTapWidget(
action.getTabListVo().tabList ?? [],
action.getTabListVo().tabList,
action.sellingTabs,
anchorKey: anchorKey,
sellTab: tabListVo.sellTab,
onChange: (int index, bool enable) {
tabListVo?.tabList[index].open = enable;
tabListVo.tabList[index].open = enable;
tabListVo.notifyListener(true);
}, onChangeSort: (Map<String, dynamic> data) {
tabListVo.sellTab = data;
tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(page: 1);
_priceAction!.qryProductListEvent(page: 1);
double offset = _scrollViewController.offset;
if (offset > 70.w) {
_scrollViewController.animateTo(70.w,
duration: Duration(milliseconds: 50),
curve: Curves.linear);
}
}, onNodeChange: (int index, TabVo tabVo) {
}, onNodeChange: (int? index, TabVo tabVo) {
tabVo.open = false;
if (tabVo.selected != null &&
tabVo.selected['is_default'] == '1') {
tabVo.selected!['is_default'] == '1') {
tabVo.selected = null;
}
tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(page: 1);
_priceAction!.qryProductListEvent(page: 1);
double offset = _scrollViewController.offset;
if (offset > 70.w) {
_scrollViewController.animateTo(70.w,
......@@ -145,7 +145,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
child: DSProvider.value(
vo: action.getProductListVo(),
builderWidget: (BuildContext context,
ProductListVo productListVo, Widget child) {
ProductListVo productListVo, Widget? child) {
if (productListVo.productList.isEmpty) {
if (productListVo.viewState == DSViewState.busy) {
return LoadingPage(
......@@ -211,10 +211,10 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
],
),
onLoad: () {
action?.loadMore();
action.loadMore();
},
onRefresh: () {
action?.onRefresh();
action.onRefresh();
},
controller: _refreshController,
),
......@@ -229,7 +229,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
} else if (scroll.metrics.pixels <= 500 && scrollIndex.value == 1) {
scrollIndex.value = 0;
}
RenderBox renderBox = anchorKey.currentContext.findRenderObject();
RenderBox renderBox = anchorKey.currentContext!.findRenderObject() as RenderBox;
var offset =
renderBox.localToGlobal(Offset(0.0, renderBox.size.height));
if (scroll.runtimeType == ScrollStartNotification) {
......@@ -270,7 +270,7 @@ class _PricePageState extends BaseUmengPageViewItemState<PricePage>
}
@override
void onloadFailed({String msg}) {
void onloadFailed({String? msg}) {
_refreshController.loadFailed();
_refreshController.refreshCompleted(resetFooterState: true);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,20 +5,20 @@ import 'package:common_module/utils/xapp_utils.dart';
typedef OverlayTapUpCallback = void Function(OverlayWidgetBuilder overlayBuilder);
typedef OverlayWidgetBuilder = void Function(Widget overlayWidget);
typedef OverlayWidgetBuilder = void Function(Widget? overlayWidget);
class OtherWidget extends StatefulWidget {
final Widget child;
final OverlayTapUpCallback tapUpCallback;
final GestureTapCallback onCloseTap;
final Widget Function() onHeaderWidget;
final OverlayTapUpCallback? tapUpCallback;
final GestureTapCallback? onCloseTap;
final Widget Function()? onHeaderWidget;
const OtherWidget({Key key,
@required this.child,
const OtherWidget({Key? key,
required this.child,
this.tapUpCallback,
this.onCloseTap,
@required this.onHeaderWidget,
required this.onHeaderWidget,
}) : super(key: key);
@override
......@@ -28,21 +28,21 @@ class OtherWidget extends StatefulWidget {
class _OtherWidgetState extends State<OtherWidget> {
GlobalKey globalKey = GlobalKey();
OverlayEntry overlayEntry;
OverlayEntry? overlayEntry;
void onCloseEntry({bool close}) {
void onCloseEntry({bool? close}) {
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry!.remove();
overlayEntry = 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){
overlayEntry.remove();
overlayEntry!.remove();
overlayEntry = null;
}
overlayEntry = new OverlayEntry(maintainState: true,builder: (BuildContext context) {
......@@ -50,7 +50,7 @@ class _OtherWidgetState extends State<OtherWidget> {
InkWell(child:Container(height:height ,color:Colors.transparent),onTap:onCloseEntry),
Container(
alignment: Alignment.center,
child:widget.onHeaderWidget(),height:headerHeight,
child:widget.onHeaderWidget!(),height:headerHeight,
color: Colors.transparent,
),
Container(child:overlayWidget,color:Color(0xFF000000).withAlpha(102)),
......@@ -60,7 +60,7 @@ class _OtherWidgetState extends State<OtherWidget> {
),
],),color:Colors.transparent,));
});
Overlay.of(context,rootOverlay: true).insert(overlayEntry);
Overlay.of(context,rootOverlay: true)!.insert(overlayEntry!);
}
@override
......@@ -80,12 +80,12 @@ class _OtherWidgetState extends State<OtherWidget> {
child: Container(child:widget.child,alignment:Alignment.center,),
onTap:(){
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry!.remove();
overlayEntry = null;
}
RenderBox renderBox = context.findRenderObject();
RenderBox renderBox = context.findRenderObject() as RenderBox;
Offset offset = renderBox.localToGlobal(Offset.zero);
widget.tapUpCallback((Widget overlayWidget){
widget.tapUpCallback!((Widget? overlayWidget){
if(overlayWidget == null){
onCloseEntry(close:true);
}else{
......@@ -105,16 +105,16 @@ class _OtherWidgetState extends State<OtherWidget> {
class OverlayEntryHeader extends StatefulWidget {
final List<TabVo> tabList;
final String Function(TabVo) onHeaderTitle;
final void Function(int,TabVo) onTap;
const OverlayEntryHeader({ Key key,@required this.tabList,this.onHeaderTitle,this.onTap}) : super(key: key);
final String? Function(TabVo)? onHeaderTitle;
final void Function(int,TabVo)? onTap;
const OverlayEntryHeader({ Key? key,required this.tabList,this.onHeaderTitle,this.onTap}) : super(key: key);
@override
_OverlayEntryHeaderState createState() => _OverlayEntryHeaderState();
}
class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
List<TabVo> tabList;
late List<TabVo> tabList;
@override
void initState() {
......@@ -127,7 +127,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
return Row(
children:List.generate(tabList.length,(index){
TabVo tabVo = tabList[index];
String title = widget.onHeaderTitle(tabVo);
String? title = widget.onHeaderTitle!(tabVo);
return Expanded(
child:InkWell(child:Container(
alignment: Alignment.center,
......@@ -146,7 +146,7 @@ class _OverlayEntryHeaderState extends State<OverlayEntryHeader> {
)
],)
),onTap:(){
widget.onTap(index,tabVo);
widget.onTap!(index,tabVo);
},),
flex:1,
);
......
......@@ -24,7 +24,7 @@ abstract class SearchWidgetDelegate {
///
/// 设置页面isGrid
///
void setPageGrid({bool isGrid});
void setPageGrid({bool? isGrid});
}
///
......@@ -35,13 +35,13 @@ class SearchWidget extends StatefulWidget {
final List<dynamic> priceCategory;
final Map<int, dynamic> platformIconMap;
final String keywords;
final void Function(Map<String, dynamic>) onGoodDetails;
final void Function(SearchWidgetDelegate) onWidgetDelegate;
final void Function(Map<String, dynamic>)? onGoodDetails;
final void Function(SearchWidgetDelegate)? onWidgetDelegate;
const SearchWidget(
{Key key,
@required this.priceCategory,
@required this.keywords,
@required this.platformIconMap,
{Key? key,
required this.priceCategory,
required this.keywords,
required this.platformIconMap,
this.isGrid = true,
this.onGoodDetails,
this.onWidgetDelegate})
......@@ -58,7 +58,7 @@ class _SearchWidgetState extends State<SearchWidget>
IPriceActionDelegate {
RefreshController _refreshController = RefreshController();
IPriceAction<PriceVo> _priceAction;
IPriceAction<PriceVo>? _priceAction;
@override
bool get wantKeepAlive => true;
......@@ -66,11 +66,11 @@ class _SearchWidgetState extends State<SearchWidget>
@override
void initState() {
if (widget.onWidgetDelegate != null) {
widget.onWidgetDelegate(this);
widget.onWidgetDelegate!(this);
}
_priceAction = PriceAction(delegate: this);
_searchKeywords = widget.keywords;
_priceAction.setPriceCategory(
_priceAction!.setPriceCategory(
priceCategory: widget.priceCategory,
keywords: _searchKeywords,
platformIconMap: widget.platformIconMap);
......@@ -78,18 +78,18 @@ class _SearchWidgetState extends State<SearchWidget>
}
@override
void setPageGrid({bool isGrid}) {
_priceAction.getProductListVo()?.isGrid = isGrid;
_priceAction.getProductListVo()?.notifyListener(true);
void setPageGrid({bool? isGrid}) {
_priceAction!.getProductListVo().isGrid = isGrid;
_priceAction!.getProductListVo().notifyListener(true);
}
String _searchKeywords;
String? _searchKeywords;
@override
void onKeywordsSearch(String keywords) {
if (_searchKeywords != keywords) {
_searchKeywords = keywords;
_priceAction.qryProductListEvent(keywords: keywords);
_priceAction!.qryProductListEvent(keywords: keywords);
}
}
......@@ -98,7 +98,7 @@ class _SearchWidgetState extends State<SearchWidget>
Widget build(BuildContext context) {
super.build(context);
return DSProviderWidget<PriceVo, IPriceAction<PriceVo>>(
dsAction: _priceAction,
dsAction: _priceAction!,
builder: (BuildContext context, child) {
return Container(
color: Color(0xFFF5F5F5),
......@@ -115,12 +115,12 @@ class _SearchWidgetState extends State<SearchWidget>
children: [
//Tab分类Widget
buildSortHeader(
action: _priceAction, keywords: widget.keywords),
action: _priceAction!, keywords: widget.keywords),
//商品列表
DSProvider.value(
vo: _priceAction.getProductListVo(),
vo: _priceAction!.getProductListVo(),
builderWidget: (BuildContext context,
ProductListVo productListVo, Widget widget1) {
ProductListVo productListVo, Widget? widget1) {
if (productListVo.productList.isEmpty) {
if (productListVo.viewState == DSViewState.busy) {
return SliverToBoxAdapter(
......@@ -168,7 +168,7 @@ class _SearchWidgetState extends State<SearchWidget>
'remark': entity.special
};
if (widget.onGoodDetails != null) {
widget.onGoodDetails(goodDetails);
widget.onGoodDetails!(goodDetails);
}
}));
} else {
......@@ -188,7 +188,7 @@ class _SearchWidgetState extends State<SearchWidget>
'remark': entity.special
};
if (widget.onGoodDetails != null) {
widget.onGoodDetails(goodDetails);
widget.onGoodDetails!(goodDetails);
}
},
));
......@@ -201,22 +201,22 @@ class _SearchWidgetState extends State<SearchWidget>
//Tab分类Widget
Widget buildSortHeader(
{@required IPriceAction<PriceVo> action, String keywords}) {
{required IPriceAction<PriceVo> action, String? keywords}) {
return DSProvider.value(
vo: action.getTabListVo(),
builderWidget:
(BuildContext context, TabListVo tabListVo, Widget widget) {
return buildTapWidget(context, tabList: tabListVo.tabList ?? [],
(BuildContext context, TabListVo tabListVo, Widget? widget) {
return buildTapWidget(context, tabList: tabListVo.tabList,
onChange: (index, enable) {
tabListVo?.tabList[index].open = enable;
tabListVo.tabList[index].open = enable;
tabListVo.notifyListener(true);
}, onNodeChange: (int index, TabVo tabVo) {
}, onNodeChange: (int? index, TabVo tabVo) {
tabVo.open = false;
if (tabVo.selected != null && tabVo.selected['is_default'] == '1') {
if (tabVo.selected != null && tabVo.selected!['is_default'] == '1') {
tabVo.selected = null;
}
tabListVo.notifyListener(true);
_priceAction.qryProductListEvent(keywords: keywords);
_priceAction!.qryProductListEvent(keywords: keywords);
});
});
}
......@@ -228,7 +228,7 @@ class _SearchWidgetState extends State<SearchWidget>
}
@override
void onloadFailed({String msg}) {
void onloadFailed({String? msg}) {
_refreshController.loadFailed();
_refreshController.refreshCompleted(resetFooterState: true);
}
......
import 'package:flutter/cupertino.dart';
import 'package:flutter_boost/flutter_boost.dart';
///
......@@ -14,14 +13,11 @@ class NavigateUtils {
///
///
static Future<Map<dynamic, dynamic>> push({
@required String path,
required String path,
bool isNative = false,
bool needLogin = true,
Map<String, dynamic> arguments = const {},
}) async {
if (arguments == null) {
arguments = {};
}
// 记录上一个页面的名称
arguments['previousRouteName'] = _getPreviousRouteName();
dynamic result = await BoostNavigator.instance.push(
......@@ -46,10 +42,10 @@ class NavigateUtils {
/// [rootPath] 根路由路径
///
static popRoot({
@required String rootPath,
required String rootPath,
}) async {
await BoostNavigator.instance.pop().then((value) async {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo();
PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
String pageName = pageInfo?.pageName ?? '';
if (pageName.isNotEmpty && pageName != rootPath) {
await popRoot(rootPath: rootPath);
......@@ -58,8 +54,8 @@ class NavigateUtils {
}
// 获取下一个新页面的上一个页面名称(页面路径)
static String _getPreviousRouteName() {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo();
static String? _getPreviousRouteName() {
PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
var boostPath = pageInfo?.pageName;
return boostPath;
}
......
......@@ -14,11 +14,11 @@ class TextSize {
///
static Size calculateTextSize(
BuildContext context, {
String value,
double fontSize,
FontWeight fontWeight,
double maxWidth,
int maxLines,
String? value,
double? fontSize,
FontWeight? fontWeight,
required double maxWidth,
int? maxLines,
}) {
TextPainter painter = TextPainter(
///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。
......
......@@ -43,7 +43,7 @@ class TimeUtils {
return '0';
}
static String formatTime({String timestamp}) {
static String formatTime({required String timestamp}) {
int time = int.parse(timestamp);
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(time * 1000);
DateTime endDate = new DateTime.now();
......
......@@ -2,24 +2,24 @@ import 'package:flutter/material.dart';
class ImageAnimationWidget extends StatelessWidget {
final ValueNotifier<int> valueNotifier;
final List<String> images;
final String package;
final double width;
final double height;
final ValueNotifier<int>? valueNotifier;
final List<String>? images;
final String? package;
final double? width;
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
Widget build(BuildContext context) {
return ValueListenableBuilder<int>(
valueListenable: valueNotifier,
builder: (BuildContext context, int value, Widget child) {
valueListenable: valueNotifier!,
builder: (BuildContext context, int value, Widget? child) {
String image;
if(value>=0 && value < images.length){
image = images[value];
if(value>=0 && value < images!.length){
image = images![value];
}else{
image = images[0];
image = images![0];
}
return Image.asset(image,package:package,gaplessPlayback: true,width:width,height:height,);
}
......
......@@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
Widget buildAppSearchBar({
double height = 48,
Decoration decoration,
EdgeInsetsGeometry margin,
EdgeInsetsGeometry padding,
Widget left,
Widget child,
Widget right,
Decoration? decoration,
EdgeInsetsGeometry? margin,
EdgeInsetsGeometry? padding,
Widget? left,
Widget? child,
Widget? right,
}) {
return PreferredSize(
child: SafeArea(
......
......@@ -7,8 +7,8 @@ import 'package:common_module/utils/xapp_utils.dart';
class LoadingPage extends StatelessWidget {
final String msg;
final int length;
final EdgeInsetsGeometry padding;
const LoadingPage({Key key, this.padding, this.msg = '1', this.length = 6})
final EdgeInsetsGeometry? padding;
const LoadingPage({Key? key, this.padding, this.msg = '1', this.length = 6})
: super(key: key);
@override
......@@ -120,12 +120,12 @@ class LoadingPage extends StatelessWidget {
/// [onReloadTap] 重新加载按钮
///
class FailedLoadPage extends StatelessWidget {
final EdgeInsetsGeometry margin;
final EdgeInsetsGeometry? margin;
final String errorMsg;
final void Function() onContactTap;
final void Function() onReloadTap;
final void Function()? onContactTap;
final void Function()? onReloadTap;
const FailedLoadPage(
{Key key,
{Key? key,
this.margin,
this.errorMsg = '加载失败,请刷新重试',
this.onContactTap,
......@@ -195,10 +195,10 @@ class FailedLoadPage extends StatelessWidget {
}
Widget _buildButtonWidget(
{@required String text,
@required TextStyle style,
Decoration decoration,
void Function() onTap}) {
{required String text,
required TextStyle style,
Decoration? decoration,
void Function()? onTap}) {
return InkWell(
child: Container(
width: 164.w,
......
......@@ -3,11 +3,11 @@ import 'package:flutter/material.dart';
class ImageWidget extends StatelessWidget {
final String name;
final double width;
final double height;
final double? width;
final double? height;
final String package;
final BoxFit fit;
const ImageWidget({ Key key,@required this.name,this.width,this.height,this.package = 'price_module',this.fit}) : super(key: key);
final BoxFit? fit;
const ImageWidget({ Key? key,required this.name,this.width,this.height,this.package = 'price_module',this.fit}) : super(key: key);
@override
Widget build(BuildContext context) {
......
......@@ -8,27 +8,27 @@ import 'package:flutter/material.dart';
///
class ItemProduct extends StatelessWidget {
final Widget image;
final double height;
final Decoration decoration;
final EdgeInsetsGeometry margin;
final double? height;
final Decoration? decoration;
final EdgeInsetsGeometry? margin;
final EdgeInsetsGeometry rightMargin;
final EdgeInsetsGeometry? rightMargin;
final Widget title;
final Widget price;
final Widget platform;
final Widget? price;
final Widget? platform;
final void Function() onTap;
final void Function()? onTap;
const ItemProduct({
Key key,
@required this.image,
Key? key,
required this.image,
this.height,
this.decoration,
this.margin,
this.rightMargin,
@required this.title,
required this.title,
this.platform,
this.price,
this.onTap
......@@ -46,8 +46,8 @@ class ItemProduct extends StatelessWidget {
image,
Expanded(child:Container(margin:rightMargin,child:Column(crossAxisAlignment: CrossAxisAlignment.start,children: [
title,
Expanded(child:price,flex:1,),
platform
Expanded(child:price!,flex:1,),
platform!
],)))
],
),
......
......@@ -3,7 +3,7 @@ import 'package:price_module/widget/image/image_widget.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(
context: context,
builder: (BuildContext context) {
......@@ -56,9 +56,9 @@ Future<T> showPopBottomSheet<T>({BuildContext context,String pageName,Map<String
Widget _buildShareWidget(BuildContext context, String key,
{@required String name,
@required String title,
Map<String, dynamic> extras = const {}}) {
{required String name,
required String title,
Map<String, dynamic>? extras = const {}}) {
return Expanded(
child:InkWell(
child: Column(
......
......@@ -8,12 +8,12 @@ import 'package:common_module/utils/xapp_utils.dart';
class PriceGridWidget extends StatelessWidget {
final EdgeInsetsGeometry padding;
final bool shrinkWrap;
final ScrollPhysics physics;
final void Function(int) onItemTap;
final List<ProductItemEntity> list;
final ScrollPhysics? physics;
final void Function(int)? onItemTap;
final List<ProductItemEntity>? list;
final bool isHaoJia;
const PriceGridWidget(
{Key key,
{Key? key,
this.padding = const EdgeInsets.all(0),
this.shrinkWrap = false,
this.physics,
......@@ -31,15 +31,15 @@ class PriceGridWidget extends StatelessWidget {
staggeredTileBuilder: (index) => StaggeredTile.fit(2),
mainAxisSpacing: 8.w,
crossAxisSpacing: 9.w,
itemCount: list.length,
itemCount: list!.length,
itemBuilder: itemGridBuilder,
);
}
Widget itemGridBuilder(BuildContext context, int index) {
ProductItemEntity vo = list[index];
ProductItemEntity vo = list![index];
return InkWell(
onTap: () => onItemTap(index),
onTap: () => onItemTap!(index),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
......@@ -56,7 +56,7 @@ class PriceGridWidget extends StatelessWidget {
children: [
ClipRRect(
child: CachedNetworkImage(
imageUrl: vo.itemPic,
imageUrl: vo.itemPic!,
placeholder: (BuildContext c, String s) {
return Image.asset(
'assets/images/placeholder_image.png',
......@@ -77,7 +77,7 @@ class PriceGridWidget extends StatelessWidget {
width: 0.5.w, color: Color(0xFFE9E9E9)),
borderRadius: BorderRadius.all(Radius.circular(3.w))),
child: Text(
vo.platform,
vo.platform!,
style: TextStyle(
color: Color(0xFF666666),
fontSize: 10.w,
......@@ -98,19 +98,19 @@ class PriceGridWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
vo.itemTitle,
vo.itemTitle!,
maxLines: 2,
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 14.w),
overflow: TextOverflow.ellipsis,
),
vo.descriptionText.isEmpty
vo.descriptionText!.isEmpty
? Container()
: SizedBox(height: 4.w),
vo.descriptionText.isEmpty
vo.descriptionText!.isEmpty
? Container()
: Text(
vo.descriptionText,
vo.descriptionText!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
......@@ -129,7 +129,7 @@ class PriceGridWidget extends StatelessWidget {
bottomRight: Radius.circular(8.w))),
padding: EdgeInsets.symmetric(
vertical: 1.w, horizontal: 4.w),
child: Text(vo.rebate,
child: Text(vo.rebate!,
style: TextStyle(
color: Color(0xFFFF8000),
fontSize: 11.w,
......@@ -143,7 +143,7 @@ class PriceGridWidget extends StatelessWidget {
alignment: Alignment.centerLeft,
child: ListView.builder(
itemCount:
vo.tags.length >= 1 ? 1 : vo.tags.length,
vo.tags!.length >= 1 ? 1 : vo.tags!.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return Container(
......@@ -154,7 +154,7 @@ class PriceGridWidget extends StatelessWidget {
Radius.circular(2.w))),
padding:
EdgeInsets.symmetric(horizontal: 2.w),
child: Text('${vo.tags[index]}',
child: Text('${vo.tags![index]}',
style: TextStyle(
color: Color(0xFFB0B0B0),
fontSize: 11.w,
......@@ -169,7 +169,7 @@ class PriceGridWidget extends StatelessWidget {
),
SizedBox(height: 4.w),
Text(
vo.special,
vo.special!,
style: TextStyle(
color: Color(0xFFFF0400),
fontSize: 13.w,
......@@ -187,13 +187,13 @@ class PriceGridWidget extends StatelessWidget {
class PriceListWidget extends StatelessWidget {
final EdgeInsetsGeometry padding;
final bool shrinkWrap;
final ScrollPhysics physics;
final void Function(ProductItemEntity, int) onItemTap;
final ScrollPhysics? physics;
final void Function(ProductItemEntity, int)? onItemTap;
final bool scroll;
final List<ProductItemEntity> list;
final List<ProductItemEntity>? list;
final bool isHaoJia;
const PriceListWidget(
{Key key,
{Key? key,
this.padding = const EdgeInsets.all(0),
this.scroll = false,
this.shrinkWrap = false,
......@@ -208,16 +208,16 @@ class PriceListWidget extends StatelessWidget {
shrinkWrap: shrinkWrap,
physics: physics,
padding: padding,
itemCount: list.length,
itemCount: list!.length,
itemBuilder: (BuildContext context, int index) {
ProductItemEntity itemVo = list[index];
ProductItemEntity itemVo = list![index];
return _buildPriceItem(
index: index,
scroll: scroll,
itemEntity: itemVo,
onTap: () {
if (onItemTap != null) {
onItemTap(itemVo, index);
onItemTap!(itemVo, index);
}
},
);
......@@ -226,10 +226,10 @@ class PriceListWidget extends StatelessWidget {
}
Widget _buildPriceItem(
{int index,
bool scroll,
ProductItemEntity itemEntity,
void Function() onTap}) {
{required int index,
required bool scroll,
required ProductItemEntity itemEntity,
void Function()? onTap}) {
return InkWell(
child: Container(
decoration: BoxDecoration(
......@@ -261,8 +261,8 @@ class PriceListWidget extends StatelessWidget {
///
/// 好价商品条目的标题等信息
///
Widget _buildItemDetails({ProductItemEntity vo}) {
String descriptionText = vo.descriptionText;
Widget _buildItemDetails({required ProductItemEntity vo}) {
String? descriptionText = vo.descriptionText;
if (descriptionText != null && descriptionText.isNotEmpty) {
descriptionText = descriptionText.replaceAll('\n', '');
descriptionText = descriptionText.replaceAll('\r', '');
......@@ -333,7 +333,7 @@ class PriceListWidget extends StatelessWidget {
child: Container(
alignment: Alignment.centerLeft,
child: ListView.builder(
itemCount: vo.tags.length >= 1 ? 1 : vo.tags.length,
itemCount: vo.tags!.length >= 1 ? 1 : vo.tags!.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return Container(
......@@ -344,7 +344,7 @@ class PriceListWidget extends StatelessWidget {
BorderRadius.all(Radius.circular(2.w))),
padding: EdgeInsets.symmetric(horizontal: 4.w),
alignment: Alignment.center,
child: Text('${vo.tags[index]}',
child: Text('${vo.tags![index]}',
style: TextStyle(
color: Color(0xFF666666),
fontSize: 11.w,
......@@ -377,7 +377,7 @@ class PriceListWidget extends StatelessWidget {
/// [scroll] 是否滚动
///
Widget _buildLeftImage(
{@required String imageUrl, @required String source, bool scroll}) {
{required String? imageUrl, required String source, required bool scroll}) {
return Container(
width: 104.w,
height: 104.w,
......@@ -390,7 +390,7 @@ class PriceListWidget extends StatelessWidget {
package: 'price_module', width: 104.w, height: 104.w)
: ClipRRect(
child: CachedNetworkImage(
imageUrl: imageUrl,
imageUrl: imageUrl!,
placeholder: (BuildContext c, String s) {
return Image.asset(
'assets/images/placeholder_image.png',
......
......@@ -2,11 +2,11 @@ import 'package:flutter/cupertino.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class PullWidget extends StatelessWidget {
final Widget child;
final VoidCallback onRefresh;
final VoidCallback onLoad;
final RefreshController controller;
final ScrollController scrollController;
final Widget? child;
final VoidCallback? onRefresh;
final VoidCallback? onLoad;
final RefreshController? controller;
final ScrollController? scrollController;
PullWidget(
{this.child,
......@@ -21,7 +21,7 @@ class PullWidget extends StatelessWidget {
Widget build(BuildContext context) {
return SmartRefresher(
scrollController: scrollController,
controller: controller,
controller: controller!,
enablePullDown: onRefresh != null,
enablePullUp: onLoad != null,
onRefresh: onRefresh,
......
......@@ -5,7 +5,7 @@ import 'package:flutter/widgets.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: [
Container(
width:24.w,
......@@ -24,7 +24,7 @@ Widget buildTabbarButton({@required String title,@required String tabBarType,Tab
class TabbarWidget extends StatefulWidget {
final Function(TabbarController) controller;
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
_TabbarWidgetState createState() => _TabbarWidgetState();
......@@ -32,8 +32,8 @@ class TabbarWidget extends StatefulWidget {
class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,SingleTickerProviderStateMixin{
Animation<double> _animation;
AnimationController _controller;
late Animation<double> _animation;
late AnimationController _controller;
int interval = 200;
List<Image> images=[];
......@@ -78,7 +78,7 @@ class _TabbarWidgetState extends State<TabbarWidget> with TabbarController,Singl
Widget build(BuildContext context) {
return ValueListenableBuilder<int>(
valueListenable: index,
builder: (BuildContext context, int value, Widget child) {
builder: (BuildContext context, int value, Widget? child) {
return images[value];
}
);
......
......@@ -6,7 +6,7 @@ homepage: /
publish_to: none
environment:
sdk: ">=2.8.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.17.0 <2.0.0"
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