Commit c3dad048 authored by 汪林玲's avatar 汪林玲

加入null-safety引入说明

parent 852a6234
...@@ -48,4 +48,11 @@ NavigateUtils.push(path:'新页面的路径',isNative:'是否打开新的容器' ...@@ -48,4 +48,11 @@ NavigateUtils.push(path:'新页面的路径',isNative:'是否打开新的容器'
FileCacheUtils.getInstance().downloadFile(filePath:'待下载的文件路径').then((value){}) FileCacheUtils.getInstance().downloadFile(filePath:'待下载的文件路径').then((value){})
``` ```
### ### 引用说明
\ No newline at end of file ```
common_module:
git:
url: 'git@git.xiaomanxiong.com:flutter-plugin/common_module.git'
ref: 'null-safety'
```
...@@ -8,7 +8,7 @@ import './base_tab_bar_view_item_state.dart'; ...@@ -8,7 +8,7 @@ import './base_tab_bar_view_item_state.dart';
/// 需要在MaterialApp.navigatorObservers中注册BaseRouteState.baseRouteStateObserver /// 需要在MaterialApp.navigatorObservers中注册BaseRouteState.baseRouteStateObserver
abstract class BasePageViewItemState<T extends StatefulWidget> abstract class BasePageViewItemState<T extends StatefulWidget>
extends BaseRouteWeigetState<T> with AutomaticKeepAliveClientMixin { extends BaseRouteWeigetState<T> with AutomaticKeepAliveClientMixin {
PageController _oldController; PageController? _oldController;
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
...@@ -45,17 +45,17 @@ abstract class BasePageViewItemState<T extends StatefulWidget> ...@@ -45,17 +45,17 @@ abstract class BasePageViewItemState<T extends StatefulWidget>
} }
void _addParentListener() { void _addParentListener() {
BasePageViewItemState pstate = BasePageViewItemState? pstate =
context.findAncestorStateOfType<BasePageViewItemState>(); context.findAncestorStateOfType<BasePageViewItemState>();
if (pstate != null && pstate.getPageController() != null) { if (pstate != null && pstate.getPageController() != null) {
pstate.getPageController().addListener(() { pstate.getPageController().addListener(() {
getPageController().notifyListeners(); getPageController().notifyListeners();
}); });
} }
BaseTabBarViewItemState tstate = BaseTabBarViewItemState? tstate =
context.findAncestorStateOfType<BaseTabBarViewItemState>(); context.findAncestorStateOfType<BaseTabBarViewItemState>();
if (tstate != null && tstate.getTabController() != null) { if (tstate != null && tstate.getTabController() != null) {
tstate.getTabController().addListener(() { tstate.getTabController()!.addListener(() {
getPageController().notifyListeners(); getPageController().notifyListeners();
}); });
} }
...@@ -74,17 +74,17 @@ abstract class BasePageViewItemState<T extends StatefulWidget> ...@@ -74,17 +74,17 @@ abstract class BasePageViewItemState<T extends StatefulWidget>
} }
PageController getPageController() { PageController getPageController() {
PageView pageView = _getPageView(); PageView pageView = _getPageView()!;
return pageView.controller; return pageView.controller;
} }
PageView _getPageView() { PageView? _getPageView() {
PageView pageView = context.findAncestorWidgetOfExactType<PageView>(); PageView? pageView = context.findAncestorWidgetOfExactType<PageView>();
return pageView; return pageView;
} }
List<Widget> _getTabs() { List<Widget> _getTabs() {
PageView pageView = _getPageView(); PageView pageView = _getPageView()!;
SliverChildListDelegate delegate = SliverChildListDelegate delegate =
pageView.childrenDelegate as SliverChildListDelegate; pageView.childrenDelegate as SliverChildListDelegate;
return delegate.children; return delegate.children;
...@@ -92,12 +92,12 @@ abstract class BasePageViewItemState<T extends StatefulWidget> ...@@ -92,12 +92,12 @@ abstract class BasePageViewItemState<T extends StatefulWidget>
bool isCurrent() { bool isCurrent() {
if (isParentCurrent()) { if (isParentCurrent()) {
List<ScrollPosition> positions = getPageController().positions; List<ScrollPosition> positions = getPageController().positions as List<ScrollPosition>;
for (int i = 0, len = positions.length; i < len; i++) { for (int i = 0, len = positions.length; i < len; i++) {
var position = positions[i]; var position = positions[i];
var pixels = getPageFromPixels( var pixels = getPageFromPixels(
position.pixels.clamp( position.pixels.clamp(
position.minScrollExtent, position.maxScrollExtent) as double, position.minScrollExtent, position.maxScrollExtent),
position.viewportDimension); position.viewportDimension);
int index = pixels.round(); int index = pixels.round();
var currentWidget = _getTabs()[index]; var currentWidget = _getTabs()[index];
...@@ -115,9 +115,9 @@ abstract class BasePageViewItemState<T extends StatefulWidget> ...@@ -115,9 +115,9 @@ abstract class BasePageViewItemState<T extends StatefulWidget>
} }
bool isParentCurrent() { bool isParentCurrent() {
BasePageViewItemState pstate = BasePageViewItemState? pstate =
context.findAncestorStateOfType<BasePageViewItemState>(); context.findAncestorStateOfType<BasePageViewItemState>();
BaseTabBarViewItemState tstate = BaseTabBarViewItemState? tstate =
context.findAncestorStateOfType<BaseTabBarViewItemState>(); context.findAncestorStateOfType<BaseTabBarViewItemState>();
if (pstate != null) { if (pstate != null) {
return pstate.isCurrent(); return pstate.isCurrent();
......
...@@ -67,7 +67,7 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T> ...@@ -67,7 +67,7 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T>
if (_isResumed) { if (_isResumed) {
return; return;
} }
ModalRoute route = ModalRoute.of(context); ModalRoute? route = ModalRoute.of(context);
if (route == null) { if (route == null) {
return; return;
} }
...@@ -82,7 +82,7 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T> ...@@ -82,7 +82,7 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T>
if (!_isResumed) { if (!_isResumed) {
return; return;
} }
ModalRoute route = ModalRoute.of(context); ModalRoute? route = ModalRoute.of(context);
if (route == null) { if (route == null) {
return; return;
} }
...@@ -116,14 +116,14 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T> ...@@ -116,14 +116,14 @@ abstract class BaseRouteWeigetState<T extends StatefulWidget> extends State<T>
void onAppPause() {} void onAppPause() {}
/// 获取路由名称 /// 获取路由名称
String getRouteName() { String? getRouteName() {
PageInfo info = BoostNavigator.instance.getTopByContext(context); PageInfo info = BoostNavigator.instance.getTopByContext(context)!;
return info.pageName; return info.pageName;
} }
/// 获取路由参数 /// 获取路由参数
T getRouteArgs<T>() { T? getRouteArgs<T>() {
PageInfo info = BoostNavigator.instance.getTopByContext(context); PageInfo info = BoostNavigator.instance.getTopByContext(context)!;
return info.arguments as T; return info.arguments as T?;
} }
} }
...@@ -6,7 +6,7 @@ import './base_page_view_item_state.dart'; ...@@ -6,7 +6,7 @@ import './base_page_view_item_state.dart';
/// 需要在MaterialApp.navigatorObservers中注册BaseRouteState.baseRouteStateObserver /// 需要在MaterialApp.navigatorObservers中注册BaseRouteState.baseRouteStateObserver
abstract class BaseTabBarViewItemState<T extends StatefulWidget> abstract class BaseTabBarViewItemState<T extends StatefulWidget>
extends BaseRouteWeigetState<T> with AutomaticKeepAliveClientMixin { extends BaseRouteWeigetState<T> with AutomaticKeepAliveClientMixin {
TabController _oldController; TabController? _oldController;
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
...@@ -35,24 +35,24 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget> ...@@ -35,24 +35,24 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget>
void _addListener() { void _addListener() {
if (wantKeepAlive && _oldController != getTabController()) { if (wantKeepAlive && _oldController != getTabController()) {
_oldController = getTabController(); _oldController = getTabController();
getTabController().addListener(_controllerListener); getTabController()!.addListener(_controllerListener);
} }
_addParentListener(); _addParentListener();
} }
void _addParentListener() { void _addParentListener() {
BasePageViewItemState pstate = BasePageViewItemState? pstate =
context.findAncestorStateOfType<BasePageViewItemState>(); context.findAncestorStateOfType<BasePageViewItemState>();
if (pstate != null && pstate.getPageController() != null) { if (pstate != null && pstate.getPageController() != null) {
pstate.getPageController().addListener(() { pstate.getPageController().addListener(() {
getTabController().notifyListeners(); getTabController()!.notifyListeners();
}); });
} }
BaseTabBarViewItemState tstate = BaseTabBarViewItemState? tstate =
context.findAncestorStateOfType<BaseTabBarViewItemState>(); context.findAncestorStateOfType<BaseTabBarViewItemState>();
if (tstate != null && tstate.getTabController() != null) { if (tstate != null && tstate.getTabController() != null) {
tstate.getTabController().addListener(() { tstate.getTabController()!.addListener(() {
getTabController().notifyListeners(); getTabController()!.notifyListeners();
}); });
} }
} }
...@@ -69,8 +69,8 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget> ...@@ -69,8 +69,8 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget>
} }
} }
TabController getTabController() { TabController? getTabController() {
TabBarView tabBarView = _getTabBarView(); TabBarView tabBarView = _getTabBarView()!;
if (tabBarView.controller != null) { if (tabBarView.controller != null) {
return tabBarView.controller; return tabBarView.controller;
} else { } else {
...@@ -78,17 +78,17 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget> ...@@ -78,17 +78,17 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget>
} }
} }
TabBarView _getTabBarView() { TabBarView? _getTabBarView() {
TabBarView tabBarView = context.findAncestorWidgetOfExactType<TabBarView>(); TabBarView? tabBarView = context.findAncestorWidgetOfExactType<TabBarView>();
return tabBarView; return tabBarView;
} }
List<Widget> _getTabs() { List<Widget> _getTabs() {
return _getTabBarView().children; return _getTabBarView()!.children;
} }
bool isCurrent() { bool isCurrent() {
var currentWidget = _getTabs()[getTabController().index]; var currentWidget = _getTabs()[getTabController()!.index];
/*if (currentWidget /*if (currentWidget
is extended.NestedScrollViewInnerScrollPositionKeyWidget) { is extended.NestedScrollViewInnerScrollPositionKeyWidget) {
currentWidget = (currentWidget as extended.NestedScrollViewInnerScrollPositionKeyWidget).child; currentWidget = (currentWidget as extended.NestedScrollViewInnerScrollPositionKeyWidget).child;
...@@ -97,9 +97,9 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget> ...@@ -97,9 +97,9 @@ abstract class BaseTabBarViewItemState<T extends StatefulWidget>
} }
bool isParentCurrent() { bool isParentCurrent() {
BasePageViewItemState pstate = BasePageViewItemState? pstate =
context.findAncestorStateOfType<BasePageViewItemState>(); context.findAncestorStateOfType<BasePageViewItemState>();
BaseTabBarViewItemState tstate = BaseTabBarViewItemState? tstate =
context.findAncestorStateOfType<BaseTabBarViewItemState>(); context.findAncestorStateOfType<BaseTabBarViewItemState>();
if (pstate != null) { if (pstate != null) {
return pstate.isCurrent(); return pstate.isCurrent();
......
...@@ -8,16 +8,16 @@ abstract class BaseUmengRouteWeigetState<T extends StatefulWidget> ...@@ -8,16 +8,16 @@ abstract class BaseUmengRouteWeigetState<T extends StatefulWidget>
@override @override
void onResume() { void onResume() {
super.onResume(); super.onResume();
String routeName = getRouteName(); String? routeName = getRouteName();
print('onResume=>>>>>>$routeName'); print('onResume=>>>>>>$routeName');
UmengUtils.onPageStart(getRouteName(), getRouteArgs()); UmengUtils.onPageStart(getRouteName()!, getRouteArgs());
} }
@override @override
void onPause() { void onPause() {
super.onPause(); super.onPause();
String routeName = getRouteName(); String? routeName = getRouteName();
print('onPause=>>>>>>$routeName'); print('onPause=>>>>>>$routeName');
UmengUtils.onPageEnd(getRouteName(), getRouteArgs()); UmengUtils.onPageEnd(getRouteName()!, getRouteArgs());
} }
} }
library common_module; library common_module;
/// A Calculator. export 'widget/ds_frame.dart';
class Calculator { \ No newline at end of file
/// Returns [value] plus 1.
int addOne(int value) => value + 1;
}
...@@ -6,10 +6,10 @@ import '../utils/xapp_utils.dart'; ...@@ -6,10 +6,10 @@ import '../utils/xapp_utils.dart';
class IAppBar extends StatelessWidget implements PreferredSizeWidget { class IAppBar extends StatelessWidget implements PreferredSizeWidget {
final double _height = 44.rpx; final double _height = 44.rpx;
final Color color; final Color color;
final String title; final String? title;
final Widget child; final Widget? child;
final double elevation; final double elevation;
final List<Widget> actions; final List<Widget>? actions;
final bool leading; final bool leading;
IAppBar( IAppBar(
{this.child, {this.child,
...@@ -24,7 +24,7 @@ class IAppBar extends StatelessWidget implements PreferredSizeWidget { ...@@ -24,7 +24,7 @@ class IAppBar extends StatelessWidget implements PreferredSizeWidget {
double luminance = color.computeLuminance(); double luminance = color.computeLuminance();
Color titleColor = luminance < 0.5 ? Colors.white : Colors.black; Color titleColor = luminance < 0.5 ? Colors.white : Colors.black;
Brightness style = luminance < 0.5 ? Brightness.dark : Brightness.light; Brightness style = luminance < 0.5 ? Brightness.dark : Brightness.light;
Widget leadingWidget; Widget? leadingWidget;
if (leading == true) { if (leading == true) {
leadingWidget = IconButton( leadingWidget = IconButton(
color: titleColor, color: titleColor,
...@@ -59,7 +59,7 @@ class IAppBar extends StatelessWidget implements PreferredSizeWidget { ...@@ -59,7 +59,7 @@ class IAppBar extends StatelessWidget implements PreferredSizeWidget {
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
child: child ?? child: child ??
Text( Text(
title, title!,
), ),
), ),
), ),
......
...@@ -6,16 +6,16 @@ class IEmptyStatus extends StatefulWidget { ...@@ -6,16 +6,16 @@ class IEmptyStatus extends StatefulWidget {
// 距离顶部padding // 距离顶部padding
final double paddingTop; final double paddingTop;
// 显示的图标 // 显示的图标
final String icon; final String? icon;
final double iconSize; final double? iconSize;
// 提示信息 // 提示信息
final String msg; final String msg;
// 按钮文字 // 按钮文字
final String btnText; final String btnText;
final Color btnColor; final Color? btnColor;
final double btnRadius; final double? btnRadius;
// 点击按钮回调,netWorkConnectd 网络是否连接 // 点击按钮回调,netWorkConnectd 网络是否连接
final Function(bool netWorkConnectd) onTap; final Function(bool netWorkConnectd)? onTap;
IEmptyStatus( IEmptyStatus(
{this.paddingTop = 139, {this.paddingTop = 139,
...@@ -25,7 +25,7 @@ class IEmptyStatus extends StatefulWidget { ...@@ -25,7 +25,7 @@ class IEmptyStatus extends StatefulWidget {
this.btnRadius, this.btnRadius,
this.onTap, this.onTap,
this.iconSize, this.iconSize,
Key key, Key? key,
this.icon}) this.icon})
: super(key: key); : super(key: key);
...@@ -38,7 +38,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> { ...@@ -38,7 +38,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> {
bool netWorkConnected = true; bool netWorkConnected = true;
// 真正显示的icon // 真正显示的icon
String get _icon { String? get _icon {
if (!netWorkConnected) { if (!netWorkConnected) {
return "assets/network_status_icon.png"; return "assets/network_status_icon.png";
} }
...@@ -77,7 +77,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> { ...@@ -77,7 +77,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Image.asset( Image.asset(
_icon, _icon!,
width: widget.iconSize ?? 261.rpx, width: widget.iconSize ?? 261.rpx,
), ),
Padding( Padding(
...@@ -97,7 +97,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> { ...@@ -97,7 +97,7 @@ class _IEmptyStatusState extends State<IEmptyStatus> {
await (new Connectivity().checkConnectivity()); await (new Connectivity().checkConnectivity());
var netWorkConnected = var netWorkConnected =
connectivityResult != ConnectivityResult.none; connectivityResult != ConnectivityResult.none;
widget.onTap(netWorkConnected); widget.onTap!(netWorkConnected);
} }
}, },
child: ClipRRect( child: ClipRRect(
......
...@@ -7,30 +7,30 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function( ...@@ -7,30 +7,30 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(
typedef NestedScrollViewPinnedHeaderSliverHeightBuilder = double Function(); typedef NestedScrollViewPinnedHeaderSliverHeightBuilder = double Function();
class INestedScrollView extends StatelessWidget { class INestedScrollView extends StatelessWidget {
final ScrollController controller; final ScrollController? controller;
final TabController tabController; final TabController? tabController;
final Axis scrollDirection; final Axis scrollDirection;
final bool reverse; final bool reverse;
final ScrollPhysics physics; final ScrollPhysics? physics;
final NestedScrollViewHeaderSliversBuilder headerSliverBuilder; final NestedScrollViewHeaderSliversBuilder headerSliverBuilder;
final NestedScrollViewPinnedHeaderSliverHeightBuilder final NestedScrollViewPinnedHeaderSliverHeightBuilder?
pinnedHeaderSliverHeightBuilder; pinnedHeaderSliverHeightBuilder;
final Widget body; final Widget body;
final DragStartBehavior dragStartBehavior; final DragStartBehavior dragStartBehavior;
final bool floatHeaderSlivers; final bool floatHeaderSlivers;
final Clip clipBehavior; final Clip clipBehavior;
final String restorationId; final String? restorationId;
INestedScrollView( INestedScrollView(
{Key key, {Key? key,
this.controller, this.controller,
this.tabController, this.tabController,
this.scrollDirection = Axis.vertical, this.scrollDirection = Axis.vertical,
this.reverse = false, this.reverse = false,
this.physics, this.physics,
this.pinnedHeaderSliverHeightBuilder, this.pinnedHeaderSliverHeightBuilder,
@required this.headerSliverBuilder, required this.headerSliverBuilder,
@required this.body, required this.body,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
this.floatHeaderSlivers = false, this.floatHeaderSlivers = false,
this.clipBehavior = Clip.hardEdge, this.clipBehavior = Clip.hardEdge,
...@@ -55,14 +55,14 @@ class INestedScrollView extends StatelessWidget { ...@@ -55,14 +55,14 @@ class INestedScrollView extends StatelessWidget {
} }
class INestedTabBarView extends StatelessWidget { class INestedTabBarView extends StatelessWidget {
final Key key; final Key? key;
final TabController controller; final TabController? controller;
final ScrollPhysics physics; final ScrollPhysics? physics;
final DragStartBehavior dragStartBehavior; final DragStartBehavior dragStartBehavior;
final List<Widget> children; final List<Widget> children;
INestedTabBarView({ INestedTabBarView({
this.key, this.key,
@required this.children, required this.children,
this.controller, this.controller,
this.physics, this.physics,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
......
...@@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; ...@@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
import 'dart:math' as math; import 'dart:math' as math;
class PersistentHeaderDelegate extends SliverPersistentHeaderDelegate { class PersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
final Widget child; final Widget? child;
final double minHeight; final double minHeight;
final double maxHeight; final double maxHeight;
final Widget Function( final Widget Function(
BuildContext context, double shrinkOffset, bool overlapsContent) builder; BuildContext context, double shrinkOffset, bool overlapsContent)? builder;
@override @override
double get minExtent => minHeight; double get minExtent => minHeight;
...@@ -17,15 +17,15 @@ class PersistentHeaderDelegate extends SliverPersistentHeaderDelegate { ...@@ -17,15 +17,15 @@ class PersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
PersistentHeaderDelegate( PersistentHeaderDelegate(
{this.child, {this.child,
this.builder, this.builder,
@required this.maxHeight, required this.maxHeight,
@required this.minHeight}); required this.minHeight});
@override @override
Widget build( Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) { BuildContext context, double shrinkOffset, bool overlapsContent) {
if (builder != null) { if (builder != null) {
return builder(context, shrinkOffset, overlapsContent); return builder!(context, shrinkOffset, overlapsContent);
} }
return child; return child!;
} }
@override @override
......
...@@ -6,7 +6,7 @@ class NavTabBarEvent { ...@@ -6,7 +6,7 @@ class NavTabBarEvent {
NavTabBarEnum tabEnum; NavTabBarEnum tabEnum;
int index; int index;
String key; String key;
Map<String, dynamic> arguments; Map<String, dynamic>? arguments;
NavTabBarEvent({this.index = 0,this.key = 'home',this.arguments, this.tabEnum = NavTabBarEnum.IndexChange}); NavTabBarEvent({this.index = 0,this.key = 'home',this.arguments, this.tabEnum = NavTabBarEnum.IndexChange});
} }
......
...@@ -2,9 +2,9 @@ import 'package:alarm_calendar/alarm_calendar_plugin.dart'; ...@@ -2,9 +2,9 @@ import 'package:alarm_calendar/alarm_calendar_plugin.dart';
export 'package:alarm_calendar/calendars.dart'; export 'package:alarm_calendar/calendars.dart';
class AlarmCalendarUtils { class AlarmCalendarUtils {
static AlarmCalendarUtils _instance; static AlarmCalendarUtils? _instance;
static AlarmCalendarUtils getInstance() { static AlarmCalendarUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new AlarmCalendarUtils._(); _instance = new AlarmCalendarUtils._();
} }
...@@ -13,7 +13,7 @@ class AlarmCalendarUtils { ...@@ -13,7 +13,7 @@ class AlarmCalendarUtils {
AlarmCalendarUtils._(); AlarmCalendarUtils._();
Future<String> create(Calendars calendars) { Future<String?> create(Calendars calendars) {
return AlarmCalendar.createEvent(calendars); return AlarmCalendar.createEvent(calendars);
} }
...@@ -21,11 +21,11 @@ class AlarmCalendarUtils { ...@@ -21,11 +21,11 @@ class AlarmCalendarUtils {
return AlarmCalendar.selectEvent(eventId); return AlarmCalendar.selectEvent(eventId);
} }
Future<bool> deleteEvent(String eventId) { Future<bool?> deleteEvent(String eventId) {
return AlarmCalendar.deleteEvent(eventId); return AlarmCalendar.deleteEvent(eventId);
} }
Future<String> updateEvent(Calendars calendars) { Future<String?> updateEvent(Calendars calendars) {
return AlarmCalendar.updateEvent(calendars); return AlarmCalendar.updateEvent(calendars);
} }
} }
...@@ -6,9 +6,9 @@ import 'package:life_repository/life_repository.dart'; ...@@ -6,9 +6,9 @@ import 'package:life_repository/life_repository.dart';
const String key = '1a7c708f0a1f5164dfc4e2e0aae34451'; const String key = '1a7c708f0a1f5164dfc4e2e0aae34451';
class AmapUtils { class AmapUtils {
static AmapUtils _instance; static AmapUtils? _instance;
static AmapUtils getInstance() { static AmapUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new AmapUtils(); _instance = new AmapUtils();
} }
...@@ -19,35 +19,35 @@ class AmapUtils { ...@@ -19,35 +19,35 @@ class AmapUtils {
/// 获取当前的定位信息 /// 获取当前的定位信息
/// ///
Future<LocationEntity> getLocation() { Future<LocationEntity> getLocation() {
return AmapsLocation.create().getLocation(apiKey: key); return AmapsLocation.create()!.getLocation(apiKey: key);
} }
/// ///
/// GPS 是否打开 /// GPS 是否打开
/// ///
Future<bool> get isOpenGPS async { Future<bool?> get isOpenGPS async {
return AmapsLocation.create().isOpenGPS(); return AmapsLocation.create()!.isOpenGPS();
} }
/// ///
/// 打开GPS /// 打开GPS
/// ///
Future<bool> enableGPS() async { Future<bool?> enableGPS() async {
return AmapsLocation.create().enableGPS(); return AmapsLocation.create()!.enableGPS();
} }
/// 判断权限 /// 判断权限
Future<bool> hasPermission() async { Future<bool> hasPermission() async {
return LocationPermissionUtils.getInstance().hasPermission(); return LocationPermissionUtils.getInstance()!.hasPermission();
} }
/// 请求权限 /// 请求权限
Future<bool> reqPermission() async { Future<bool> reqPermission() async {
return LocationPermissionUtils.getInstance().reqPermission(); return LocationPermissionUtils.getInstance()!.reqPermission();
} }
// 地址转gps // 地址转gps
Future<String> addressToGps(String address, [String city]) { Future<String?> addressToGps(String address, [String? city]) {
return AMapRepository.get() return AMapRepository.get()
.addressToGps(key: key, address: address, city: city); .addressToGps(key: key, address: address, city: city);
} }
......
class AppTapConfigUtils { class AppTapConfigUtils {
static AppTapConfigUtils _instance; static AppTapConfigUtils? _instance;
static AppTapConfigUtils getInstance() { static AppTapConfigUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new AppTapConfigUtils(); _instance = new AppTapConfigUtils();
} }
return _instance; return _instance;
} }
OnActivityConfigTapListener _activityConfigTapListener; OnActivityConfigTapListener? _activityConfigTapListener;
OnGoodsTapListener _goodsTapListener; OnGoodsTapListener? _goodsTapListener;
OnPriceGoodsTapListener _priceGoodsTapListener; OnPriceGoodsTapListener? _priceGoodsTapListener;
void activityConfigTap(Map<String, dynamic> jsonStr) { void activityConfigTap(Map<String, dynamic> jsonStr) {
if (_activityConfigTapListener != null) { if (_activityConfigTapListener != null) {
_activityConfigTapListener(jsonStr); _activityConfigTapListener!(jsonStr);
} }
} }
...@@ -26,13 +26,13 @@ class AppTapConfigUtils { ...@@ -26,13 +26,13 @@ class AppTapConfigUtils {
} }
void priceGoodsTap({ void priceGoodsTap({
String productId, String? productId,
String src, String? src,
String title, String? title,
String remark, String? remark,
}) { }) {
if (_priceGoodsTapListener != null) { if (_priceGoodsTapListener != null) {
_priceGoodsTapListener( _priceGoodsTapListener!(
productId: productId, productId: productId,
src: src, src: src,
title: title, title: title,
...@@ -42,13 +42,13 @@ class AppTapConfigUtils { ...@@ -42,13 +42,13 @@ class AppTapConfigUtils {
} }
void goodsTap({ void goodsTap({
String platform, String? platform,
String itemId, String? itemId,
Map goodsItem, Map? goodsItem,
String tabviewId, String? tabviewId,
}) { }) {
if (_goodsTapListener != null) { if (_goodsTapListener != null) {
_goodsTapListener( _goodsTapListener!(
platform: platform, platform: platform,
itemId: itemId, itemId: itemId,
goodsItem: goodsItem, goodsItem: goodsItem,
...@@ -64,14 +64,14 @@ class AppTapConfigUtils { ...@@ -64,14 +64,14 @@ class AppTapConfigUtils {
typedef OnActivityConfigTapListener = Function(Map<String, dynamic> jsonStr); typedef OnActivityConfigTapListener = Function(Map<String, dynamic> jsonStr);
typedef OnGoodsTapListener = Function({ typedef OnGoodsTapListener = Function({
String platform, String? platform,
String itemId, String? itemId,
Map goodsItem, Map? goodsItem,
String tabviewId, String? tabviewId,
}); });
typedef OnPriceGoodsTapListener = Function({ typedef OnPriceGoodsTapListener = Function({
String productId, String? productId,
String src, String? src,
String title, String? title,
String remark, String? remark,
}); });
...@@ -4,9 +4,9 @@ const String _AUDIT_MODE_CACHE_KEY = ""; ...@@ -4,9 +4,9 @@ const String _AUDIT_MODE_CACHE_KEY = "";
/// 审核模式工具类 /// 审核模式工具类
class AuditModeUtils { class AuditModeUtils {
static AuditModeUtils _instance; static AuditModeUtils? _instance;
static AuditModeUtils getInstance() { static AuditModeUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new AuditModeUtils._(); _instance = new AuditModeUtils._();
} }
...@@ -15,14 +15,14 @@ class AuditModeUtils { ...@@ -15,14 +15,14 @@ class AuditModeUtils {
AuditModeUtils._(); AuditModeUtils._();
String _isAuditMode; String? _isAuditMode;
String _adSwitch; String? _adSwitch;
// 获取是否审核模式 // 获取是否审核模式
bool isAuditMode() { bool isAuditMode() {
if (_isAuditMode == null) { if (_isAuditMode == null) {
_isAuditMode = _isAuditMode =
StoreUtils.getInstance().getForKey(key: _AUDIT_MODE_CACHE_KEY,defaultValue: null); StoreUtils.getInstance()!.getForKey(key: _AUDIT_MODE_CACHE_KEY,defaultValue: null);
} }
return _isAuditMode == '1'; return _isAuditMode == '1';
} }
...@@ -40,7 +40,7 @@ class AuditModeUtils { ...@@ -40,7 +40,7 @@ class AuditModeUtils {
} }
void setAuditMode(String isAuditMode) { void setAuditMode(String isAuditMode) {
StoreUtils.getInstance().setKV(key: _AUDIT_MODE_CACHE_KEY, value: isAuditMode); StoreUtils.getInstance()!.setKV(key: _AUDIT_MODE_CACHE_KEY, value: isAuditMode);
_isAuditMode = isAuditMode; _isAuditMode = isAuditMode;
} }
} }
...@@ -9,7 +9,7 @@ class ClipboardUtils { ...@@ -9,7 +9,7 @@ class ClipboardUtils {
//复制到剪贴板 //复制到剪贴板
static Future<bool> copyText(String text) async { static Future<bool> copyText(String text) async {
//如果是本app内复制的,存起来不识别 //如果是本app内复制的,存起来不识别
StoreUtils.getInstance().setKV(key: LOCAL_COPY_TEXT_KEY, value: text); StoreUtils.getInstance()!.setKV(key: LOCAL_COPY_TEXT_KEY, value: text);
if (Platform.isIOS) { if (Platform.isIOS) {
await Clipboard.setData(ClipboardData(text: text)); await Clipboard.setData(ClipboardData(text: text));
return true; return true;
...@@ -19,7 +19,7 @@ class ClipboardUtils { ...@@ -19,7 +19,7 @@ class ClipboardUtils {
} }
//获取剪贴板文字 //获取剪贴板文字
static Future<String> getAppClipboardText() async { static Future<String?> getAppClipboardText() async {
if (Platform.isIOS) { if (Platform.isIOS) {
var data = await Clipboard.getData(Clipboard.kTextPlain); var data = await Clipboard.getData(Clipboard.kTextPlain);
if (data == null) { if (data == null) {
...@@ -45,7 +45,7 @@ class ClipboardUtils { ...@@ -45,7 +45,7 @@ class ClipboardUtils {
} }
// 获取本地复制的文本 // 获取本地复制的文本
static String getLocalCopyText() { static String? getLocalCopyText() {
return StoreUtils.getInstance().getForKey(key: LOCAL_COPY_TEXT_KEY,defaultValue:''); return StoreUtils.getInstance()!.getForKey(key: LOCAL_COPY_TEXT_KEY,defaultValue:'');
} }
} }
...@@ -48,13 +48,13 @@ Map<int, int> monthDay = { ...@@ -48,13 +48,13 @@ Map<int, int> monthDay = {
/// Date Util. /// Date Util.
class DateUtil { class DateUtil {
/// get DateTime By DateStr. /// get DateTime By DateStr.
static DateTime getDateTime(String dateStr, {bool isUtc}) { static DateTime? getDateTime(String dateStr, {bool? isUtc}) {
DateTime dateTime = DateTime.tryParse(dateStr); DateTime? dateTime = DateTime.tryParse(dateStr);
if (isUtc != null) { if (isUtc != null) {
if (isUtc) { if (isUtc) {
dateTime = dateTime.toUtc(); dateTime = dateTime!.toUtc();
} else { } else {
dateTime = dateTime.toLocal(); dateTime = dateTime!.toLocal();
} }
} }
return dateTime; return dateTime;
...@@ -62,14 +62,12 @@ class DateUtil { ...@@ -62,14 +62,12 @@ class DateUtil {
/// get DateTime By Milliseconds. /// get DateTime By Milliseconds.
static DateTime getDateTimeByMs(int ms, {bool isUtc = false}) { static DateTime getDateTimeByMs(int ms, {bool isUtc = false}) {
return ms == null return DateTime.fromMillisecondsSinceEpoch(ms, isUtc: isUtc);
? null
: DateTime.fromMillisecondsSinceEpoch(ms, isUtc: isUtc);
} }
/// get DateMilliseconds By DateStr. /// get DateMilliseconds By DateStr.
static int getDateMsByTimeStr(String dateStr) { static int? getDateMsByTimeStr(String dateStr) {
DateTime dateTime = DateTime.tryParse(dateStr); DateTime? dateTime = DateTime.tryParse(dateStr);
return dateTime?.millisecondsSinceEpoch; return dateTime?.millisecondsSinceEpoch;
} }
...@@ -85,13 +83,13 @@ class DateUtil { ...@@ -85,13 +83,13 @@ class DateUtil {
/// format date by milliseconds. /// format date by milliseconds.
/// milliseconds 日期毫秒 /// milliseconds 日期毫秒
static String formatDateMs(int ms, {bool isUtc = false, String format}) { static String formatDateMs(int ms, {bool isUtc = false, String? format}) {
return formatDate(getDateTimeByMs(ms, isUtc: isUtc), format: format); return formatDate(getDateTimeByMs(ms, isUtc: isUtc), format: format);
} }
/// format date by date str. /// format date by date str.
/// dateStr 日期字符串 /// dateStr 日期字符串
static String formatDateStr(String dateStr, {bool isUtc, String format}) { static String formatDateStr(String dateStr, {bool? isUtc, String? format}) {
return formatDate(getDateTime(dateStr, isUtc: isUtc), format: format); return formatDate(getDateTime(dateStr, isUtc: isUtc), format: format);
} }
...@@ -100,7 +98,7 @@ class DateUtil { ...@@ -100,7 +98,7 @@ class DateUtil {
/// 格式要求 /// 格式要求
/// year -> yyyy/yy month -> MM/M day -> dd/d /// year -> yyyy/yy month -> MM/M day -> dd/d
/// hour -> HH/H minute -> mm/m second -> ss/s /// hour -> HH/H minute -> mm/m second -> ss/s
static String formatDate(DateTime dateTime, {String format}) { static String formatDate(DateTime? dateTime, {String? format}) {
if (dateTime == null) return ''; if (dateTime == null) return '';
format = format ?? DateFormats.full; format = format ?? DateFormats.full;
if (format.contains('yy')) { if (format.contains('yy')) {
...@@ -142,10 +140,10 @@ class DateUtil { ...@@ -142,10 +140,10 @@ class DateUtil {
/// isUtc /// isUtc
/// languageCode zh or en /// languageCode zh or en
/// short /// short
static String getWeekday(DateTime dateTime, static String? getWeekday(DateTime dateTime,
{String languageCode = 'en', bool short = false}) { {String? languageCode = 'en', bool short = false}) {
if (dateTime == null) return null; if (dateTime == null) return null;
String weekday; String? weekday;
switch (dateTime.weekday) { switch (dateTime.weekday) {
case 1: case 1:
weekday = languageCode == 'zh' ? '星期一' : 'Monday'; weekday = languageCode == 'zh' ? '星期一' : 'Monday';
...@@ -172,13 +170,13 @@ class DateUtil { ...@@ -172,13 +170,13 @@ class DateUtil {
break; break;
} }
return languageCode == 'zh' return languageCode == 'zh'
? (short ? weekday.replaceAll('星期', '周') : weekday) ? (short ? weekday!.replaceAll('星期', '周') : weekday)
: weekday.substring(0, short ? 3 : weekday.length); : weekday!.substring(0, short ? 3 : weekday.length);
} }
/// get WeekDay By Milliseconds. /// get WeekDay By Milliseconds.
static String getWeekdayByMs(int milliseconds, static String? getWeekdayByMs(int milliseconds,
{bool isUtc = false, String languageCode, bool short = false}) { {bool isUtc = false, String? languageCode, bool short = false}) {
DateTime dateTime = getDateTimeByMs(milliseconds, isUtc: isUtc); DateTime dateTime = getDateTimeByMs(milliseconds, isUtc: isUtc);
return getWeekday(dateTime, languageCode: languageCode, short: short); return getWeekday(dateTime, languageCode: languageCode, short: short);
} }
...@@ -190,7 +188,7 @@ class DateUtil { ...@@ -190,7 +188,7 @@ class DateUtil {
int month = dateTime.month; int month = dateTime.month;
int days = dateTime.day; int days = dateTime.day;
for (int i = 1; i < month; i++) { for (int i = 1; i < month; i++) {
days = days + monthDay[i]; days = days + monthDay[i]!;
} }
if (isLeapYearByYear(year) && month > 2) { if (isLeapYearByYear(year) && month > 2) {
days = days + 1; days = days + 1;
...@@ -206,7 +204,7 @@ class DateUtil { ...@@ -206,7 +204,7 @@ class DateUtil {
/// is today. /// is today.
/// 是否是当天. /// 是否是当天.
static bool isToday(int milliseconds, {bool isUtc = false, int locMs}) { static bool isToday(int milliseconds, {bool isUtc = false, int? locMs}) {
if (milliseconds == null || milliseconds == 0) return false; if (milliseconds == null || milliseconds == 0) return false;
DateTime old = DateTime old =
DateTime.fromMillisecondsSinceEpoch(milliseconds, isUtc: isUtc); DateTime.fromMillisecondsSinceEpoch(milliseconds, isUtc: isUtc);
...@@ -243,7 +241,7 @@ class DateUtil { ...@@ -243,7 +241,7 @@ class DateUtil {
/// is Week. /// is Week.
/// 是否是本周. /// 是否是本周.
static bool isWeek(int ms, {bool isUtc = false, int locMs}) { static bool isWeek(int ms, {bool isUtc = false, int? locMs}) {
if (ms == null || ms <= 0) { if (ms == null || ms <= 0) {
return false; return false;
} }
......
...@@ -6,8 +6,8 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; ...@@ -6,8 +6,8 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';
/// 文件缓存工具 /// 文件缓存工具
/// ///
class FileCacheUtils { class FileCacheUtils {
static FileCacheUtils _instance; static FileCacheUtils? _instance;
static FileCacheUtils getInstance() { static FileCacheUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new FileCacheUtils(); _instance = new FileCacheUtils();
} }
...@@ -18,7 +18,7 @@ class FileCacheUtils { ...@@ -18,7 +18,7 @@ class FileCacheUtils {
/// 下载文件 /// 下载文件
/// [filePath] 待下载的文件路径 /// [filePath] 待下载的文件路径
/// ///
Future<FileEntity> downloadFile({String filePath}) async { Future<FileEntity> downloadFile({required String filePath}) async {
FileInfo result = await DefaultCacheManager().downloadFile(filePath); FileInfo result = await DefaultCacheManager().downloadFile(filePath);
return FileEntity( return FileEntity(
file: result.file, file: result.file,
...@@ -31,15 +31,15 @@ class FileCacheUtils { ...@@ -31,15 +31,15 @@ class FileCacheUtils {
class FileEntity { class FileEntity {
FileEntity({this.file, this.source, this.validTill, this.originalUrl}); FileEntity({this.file, this.source, this.validTill, this.originalUrl});
final String originalUrl; final String? originalUrl;
/// Fetched file /// Fetched file
final File file; final File? file;
/// Source from the file, can be cache or online (web). /// Source from the file, can be cache or online (web).
final int source; final int? source;
/// Validity date of the file. After this date the validity is not guaranteed /// Validity date of the file. After this date the validity is not guaranteed
/// and the CacheManager will try to update the file. /// and the CacheManager will try to update the file.
final DateTime validTill; final DateTime? validTill;
} }
...@@ -25,9 +25,9 @@ class ImagePreviewUtils { ...@@ -25,9 +25,9 @@ class ImagePreviewUtils {
// } // }
static void showIndex( static void showIndex(
{BuildContext context, {required BuildContext context,
List<String> images, List<String>? images,
String heroTag, String? heroTag,
int index = 0}) { int index = 0}) {
var route = MaterialPageRoute(builder: (context) { var route = MaterialPageRoute(builder: (context) {
return _ImagePreviewWidget( return _ImagePreviewWidget(
...@@ -42,11 +42,11 @@ class ImagePreviewUtils { ...@@ -42,11 +42,11 @@ class ImagePreviewUtils {
// 预览widget // 预览widget
class _ImagePreviewWidget extends StatefulWidget { class _ImagePreviewWidget extends StatefulWidget {
final String heroTag; final String? heroTag;
final List<String> images; final List<String>? images;
final int index; final int index;
_ImagePreviewWidget(this.images, {this.heroTag, Key key, this.index = 1}) _ImagePreviewWidget(this.images, {this.heroTag, Key? key, this.index = 1})
: super(key: key); : super(key: key);
@override @override
...@@ -56,7 +56,7 @@ class _ImagePreviewWidget extends StatefulWidget { ...@@ -56,7 +56,7 @@ class _ImagePreviewWidget extends StatefulWidget {
// 预览widget状态 // 预览widget状态
class _ImagePreviewWidgetState extends State<_ImagePreviewWidget> class _ImagePreviewWidgetState extends State<_ImagePreviewWidget>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
PageController pageController; PageController? pageController;
ValueNotifier<int> currentIndex = ValueNotifier(0); ValueNotifier<int> currentIndex = ValueNotifier(0);
@override @override
...@@ -117,7 +117,7 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget> ...@@ -117,7 +117,7 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget>
child: Container( child: Container(
child: PhotoViewGallery.builder( child: PhotoViewGallery.builder(
pageController: pageController, pageController: pageController,
itemCount: widget.images.length, itemCount: widget.images!.length,
scrollPhysics: const BouncingScrollPhysics(), scrollPhysics: const BouncingScrollPhysics(),
backgroundDecoration: null, backgroundDecoration: null,
enableRotation: true, enableRotation: true,
...@@ -131,9 +131,9 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget> ...@@ -131,9 +131,9 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget>
onTapUp: (context, d, c) { onTapUp: (context, d, c) {
Navigator.pop(context); Navigator.pop(context);
}, },
imageProvider: _buildImageProvider(widget.images[i]), imageProvider: _buildImageProvider(widget.images![i]),
heroAttributes: widget.heroTag.isNotEmpty heroAttributes: widget.heroTag!.isNotEmpty
? PhotoViewHeroAttributes(tag: widget.heroTag) ? PhotoViewHeroAttributes(tag: widget.heroTag!)
: null, : null,
); );
}), }),
...@@ -151,7 +151,7 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget> ...@@ -151,7 +151,7 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget>
// 编译索引 // 编译索引
Widget buildIndex() { Widget buildIndex() {
if (widget.images.length <= 1) { if (widget.images!.length <= 1) {
return Text(''); return Text('');
} }
...@@ -159,9 +159,9 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget> ...@@ -159,9 +159,9 @@ class _ImagePreviewWidgetState extends State<_ImagePreviewWidget>
padding: EdgeInsets.only(bottom: 20), padding: EdgeInsets.only(bottom: 20),
child: ValueListenableBuilder<int>( child: ValueListenableBuilder<int>(
valueListenable: currentIndex, valueListenable: currentIndex,
builder: (BuildContext context, int page, Widget child) { builder: (BuildContext context, int page, Widget? child) {
return Text( return Text(
"${page + 1}/${widget.images.length}", "${page + 1}/${widget.images!.length}",
style: TextStyle(color: Colors.white70), style: TextStyle(color: Colors.white70),
); );
}, },
......
...@@ -4,9 +4,9 @@ import 'package:flutter/cupertino.dart'; ...@@ -4,9 +4,9 @@ import 'package:flutter/cupertino.dart';
import 'package:common_module/components/i_empty_status.dart'; import 'package:common_module/components/i_empty_status.dart';
class ListModelStatusUtils<T extends BaseListModel> { class ListModelStatusUtils<T extends BaseListModel> {
static ListModelStatusUtils _instance; static ListModelStatusUtils? _instance;
static ListModelStatusUtils getInstance() { static ListModelStatusUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new ListModelStatusUtils._(); _instance = new ListModelStatusUtils._();
} }
...@@ -15,17 +15,17 @@ class ListModelStatusUtils<T extends BaseListModel> { ...@@ -15,17 +15,17 @@ class ListModelStatusUtils<T extends BaseListModel> {
ListModelStatusUtils._(); ListModelStatusUtils._();
Widget form( Widget? form(
{T model, {required T model,
double paddingTop = 139, double paddingTop = 139,
double loadingPaddingTop = 139, double loadingPaddingTop = 139,
String failText = '暂无数据', String failText = '暂无数据',
String btnText = "点击刷新", String btnText = "点击刷新",
Color btnColor, Color? btnColor,
double btnRadius, double? btnRadius,
String icon, String? icon,
double iconSize, double? iconSize,
Function() onTap}) { Function()? onTap}) {
// 未请求完成 && 在第一页 显示加载中 // 未请求完成 && 在第一页 显示加载中
if (!model.isRequestDone() && model.getPage() == 1) { if (!model.isRequestDone() && model.getPage() == 1) {
return Container( return Container(
......
...@@ -3,9 +3,9 @@ import 'package:flutter_boost/boost_navigator.dart'; ...@@ -3,9 +3,9 @@ import 'package:flutter_boost/boost_navigator.dart';
import './xapp_utils.dart'; import './xapp_utils.dart';
class LoadingDialogUtils { class LoadingDialogUtils {
static LoadingDialogUtils _instance; static LoadingDialogUtils? _instance;
static LoadingDialogUtils getInstance() { static LoadingDialogUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new LoadingDialogUtils._(); _instance = new LoadingDialogUtils._();
} }
...@@ -20,14 +20,14 @@ class LoadingDialogUtils { ...@@ -20,14 +20,14 @@ class LoadingDialogUtils {
} }
class LoadingDialog { class LoadingDialog {
Route route; Route? route;
LoadingDialog(String msg) { LoadingDialog(String msg) {
route = _LoadingDialogRouter(_LoadingDialog(msg)); route = _LoadingDialogRouter(_LoadingDialog(msg));
BoostNavigator.instance.appState.topContainer.navigator.push(route); BoostNavigator.instance.appState!.topContainer!.navigator!.push(route!);
} }
void close() { void close() {
if (route != null && route.navigator != null) { if (route != null && route!.navigator != null) {
route.navigator.pop(route); route!.navigator!.pop(route);
} }
} }
} }
......
...@@ -5,8 +5,8 @@ import 'package:permission_handler/permission_handler.dart'; ...@@ -5,8 +5,8 @@ import 'package:permission_handler/permission_handler.dart';
/// 定位权限相关类 /// 定位权限相关类
/// ///
class LocationPermissionUtils { class LocationPermissionUtils {
static LocationPermissionUtils _instance; static LocationPermissionUtils? _instance;
static LocationPermissionUtils getInstance() { static LocationPermissionUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new LocationPermissionUtils(); _instance = new LocationPermissionUtils();
} }
...@@ -18,7 +18,7 @@ class LocationPermissionUtils { ...@@ -18,7 +18,7 @@ class LocationPermissionUtils {
/// ///
Future<bool> hasPermission() async { Future<bool> hasPermission() async {
Map<Permission, PermissionUtilsStatus> result = Map<Permission, PermissionUtilsStatus> result =
await PermissionUtils.getInstance() await PermissionUtils.getInstance()!
.has(permissions: [Permission.location]); .has(permissions: [Permission.location]);
return result[Permission.location] == PermissionUtilsStatus.granted; return result[Permission.location] == PermissionUtilsStatus.granted;
} }
...@@ -28,14 +28,14 @@ class LocationPermissionUtils { ...@@ -28,14 +28,14 @@ class LocationPermissionUtils {
/// ///
Future<bool> reqPermission() async { Future<bool> reqPermission() async {
Map<Permission, PermissionUtilsStatus> result = Map<Permission, PermissionUtilsStatus> result =
await PermissionUtils.getInstance() await PermissionUtils.getInstance()!
.has(permissions: [Permission.location]); .has(permissions: [Permission.location]);
var location = result[Permission.location]; var location = result[Permission.location];
if (location == PermissionUtilsStatus.permanentlyDenied) { if (location == PermissionUtilsStatus.permanentlyDenied) {
PermissionUtils.getInstance().openAppSetting(); PermissionUtils.getInstance()!.openAppSetting();
return false; return false;
} else if (location == PermissionUtilsStatus.denied) { } else if (location == PermissionUtilsStatus.denied) {
result = await PermissionUtils.getInstance() result = await PermissionUtils.getInstance()!
.request(permissions: [Permission.location]); .request(permissions: [Permission.location]);
location = result[Permission.location]; location = result[Permission.location];
......
...@@ -9,9 +9,9 @@ const num a = 6378245.0; ...@@ -9,9 +9,9 @@ const num a = 6378245.0;
const num ee = 0.00669342162296594323; const num ee = 0.00669342162296594323;
class MapUtils { class MapUtils {
static MapUtils instance; static MapUtils? instance;
static MapUtils getInstance() { static MapUtils? getInstance() {
if (instance == null) { if (instance == null) {
instance = new MapUtils(); instance = new MapUtils();
} }
...@@ -28,7 +28,7 @@ class MapUtils { ...@@ -28,7 +28,7 @@ class MapUtils {
} }
} }
Future<String> getMap( Future<String?> getMap(
String latitude, String longitude, String addressStr) async { String latitude, String longitude, String addressStr) async {
List<num> gps = gcj02ToBd09(num.parse(latitude), num.parse(longitude)); List<num> gps = gcj02ToBd09(num.parse(latitude), num.parse(longitude));
//'${gps[1]},${gps[0]}'; //'${gps[1]},${gps[0]}';
......
...@@ -2,9 +2,9 @@ import 'package:url_launcher/url_launcher.dart'; ...@@ -2,9 +2,9 @@ import 'package:url_launcher/url_launcher.dart';
import 'package:common_module/utils/navigate_utils.dart'; import 'package:common_module/utils/navigate_utils.dart';
class MeituanUtils { class MeituanUtils {
static MeituanUtils _instance; static MeituanUtils? _instance;
static MeituanUtils getInstance() { static MeituanUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new MeituanUtils(); _instance = new MeituanUtils();
} }
......
import 'package:common_module/eventbus/nav_tabbar_event.dart'; import 'package:common_module/eventbus/nav_tabbar_event.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_boost/flutter_boost.dart'; import 'package:flutter_boost/flutter_boost.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
...@@ -7,14 +6,14 @@ import 'event_bus_utils.dart'; ...@@ -7,14 +6,14 @@ import 'event_bus_utils.dart';
/// 路由前置拦截器 /// 路由前置拦截器
typedef PopBeforeFuntion = Future<void> Function( typedef PopBeforeFuntion = Future<void> Function(
String path, bool isNative, bool needLogin, Map<String, dynamic> arguments); String path, bool isNative, bool needLogin, Map<String, dynamic>? arguments);
/// ///
/// Boost导航路由管理器 /// Boost导航路由管理器
/// ///
class NavigateUtils { class NavigateUtils {
/// 路由前置拦截器 /// 路由前置拦截器
static PopBeforeFuntion _onPopBefore; static PopBeforeFuntion? _onPopBefore;
/// ///
/// 开启新页面统一API /// 开启新页面统一API
...@@ -25,13 +24,13 @@ class NavigateUtils { ...@@ -25,13 +24,13 @@ 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, Map<String, dynamic>? arguments,
}) async { }) async {
if (_onPopBefore != null) { if (_onPopBefore != null) {
await _onPopBefore(path, isNative, needLogin, arguments); await _onPopBefore!(path, isNative, needLogin, arguments);
} }
if (arguments == null) { if (arguments == null) {
...@@ -51,11 +50,11 @@ class NavigateUtils { ...@@ -51,11 +50,11 @@ class NavigateUtils {
/// ///
/// ///
static Future<bool> pushLaunch({ static Future<bool> pushLaunch({
@required String urlString, required String urlString,
bool needLogin = true, bool needLogin = true,
}) async { }) async {
if (_onPopBefore != null) { if (_onPopBefore != null) {
await _onPopBefore(urlString, false, needLogin, {}); await _onPopBefore!(urlString, false, needLogin, {});
} }
var urlencode = Uri.encodeComponent(urlString); var urlencode = Uri.encodeComponent(urlString);
return await launch( return await launch(
...@@ -90,14 +89,14 @@ class NavigateUtils { ...@@ -90,14 +89,14 @@ class NavigateUtils {
/// [rootPath] 根路由路径 /// [rootPath] 根路由路径
/// ///
static popRoot({ static popRoot({
@required String rootPath, required String rootPath,
Map<String, dynamic> arguments = const {} Map<String, dynamic> arguments = const {}
}) async { }) async {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo(); PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
String pageName = pageInfo?.pageName ?? ''; String pageName = pageInfo?.pageName ?? '';
if(pageName != rootPath){ if(pageName != rootPath){
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,arguments:arguments); await popRoot(rootPath: rootPath,arguments:arguments);
...@@ -112,8 +111,8 @@ class NavigateUtils { ...@@ -112,8 +111,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;
} }
......
...@@ -6,9 +6,9 @@ const String h5BaseURL = String.fromEnvironment("h5BaseURL", ...@@ -6,9 +6,9 @@ const String h5BaseURL = String.fromEnvironment("h5BaseURL",
'https://xmxcdn.xiaomanxiong.net/'); //http://flutterh5.test.xiaomanxiong.cn/ 'https://xmxcdn.xiaomanxiong.net/'); //http://flutterh5.test.xiaomanxiong.cn/
class PageUtils { class PageUtils {
static PageUtils _instance; static PageUtils? _instance;
static PageUtils getInstance() { static PageUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new PageUtils(); _instance = new PageUtils();
} }
...@@ -22,8 +22,8 @@ class PageUtils { ...@@ -22,8 +22,8 @@ class PageUtils {
/// [showRefresh] 是否显示刷新按钮 /// [showRefresh] 是否显示刷新按钮
/// [hideTitleBar] 是否隐藏标题栏 /// [hideTitleBar] 是否隐藏标题栏
Future openH5({ Future openH5({
String url, required String url,
String title, String? title,
dynamic pageParam, dynamic pageParam,
bool needLogin = true, bool needLogin = true,
bool needAuth = false, bool needAuth = false,
...@@ -80,7 +80,7 @@ class PageUtils { ...@@ -80,7 +80,7 @@ class PageUtils {
/// 打开意见反馈 /// 打开意见反馈
void openFAQ() { void openFAQ() {
PageUtils.getInstance().openH5( PageUtils.getInstance()!.openH5(
clearCache: 0, clearCache: 0,
url: 'https://wenjuan.feishu.cn/m/cfm?t=sJEKcKXY1Qni-dy5g'); url: 'https://wenjuan.feishu.cn/m/cfm?t=sJEKcKXY1Qni-dy5g');
} }
......
...@@ -3,9 +3,9 @@ import 'dart:io'; ...@@ -3,9 +3,9 @@ import 'dart:io';
export 'package:permission_handler/permission_handler.dart'; export 'package:permission_handler/permission_handler.dart';
class PermissionUtils { class PermissionUtils {
static PermissionUtils _instance; static PermissionUtils? _instance;
static PermissionUtils getInstance() { static PermissionUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new PermissionUtils(); _instance = new PermissionUtils();
} }
...@@ -15,7 +15,7 @@ class PermissionUtils { ...@@ -15,7 +15,7 @@ class PermissionUtils {
/// 判断是否有权限 /// 判断是否有权限
/// 状态进行了简化,统一 /// 状态进行了简化,统一
Future<Map<Permission, PermissionUtilsStatus>> has( Future<Map<Permission, PermissionUtilsStatus>> has(
{List<Permission> permissions}) async { {required List<Permission> permissions}) async {
assert(permissions != null && permissions.length > 0); assert(permissions != null && permissions.length > 0);
Map<Permission, PermissionUtilsStatus> resultPermissions = {}; Map<Permission, PermissionUtilsStatus> resultPermissions = {};
for (int i = 0, len = permissions.length; i < len; i++) { for (int i = 0, len = permissions.length; i < len; i++) {
...@@ -44,7 +44,7 @@ class PermissionUtils { ...@@ -44,7 +44,7 @@ class PermissionUtils {
/// 判断请求权限 /// 判断请求权限
/// 状态进行了简化,统一 /// 状态进行了简化,统一
Future<Map<Permission, PermissionUtilsStatus>> request( Future<Map<Permission, PermissionUtilsStatus>> request(
{List<Permission> permissions}) async { {required List<Permission> permissions}) async {
assert(permissions != null && permissions.length > 0); assert(permissions != null && permissions.length > 0);
Map<Permission, PermissionUtilsStatus> resultPermissions = {}; Map<Permission, PermissionUtilsStatus> resultPermissions = {};
Map<Permission, PermissionStatus> resultMap = await permissions.request(); Map<Permission, PermissionStatus> resultMap = await permissions.request();
......
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:localstorage/localstorage.dart'; import 'package:localstorage/localstorage.dart';
//import 'package:shared_preferences/shared_preferences.dart'; //import 'package:shared_preferences/shared_preferences.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
...@@ -12,13 +11,13 @@ class StoreUtils { ...@@ -12,13 +11,13 @@ class StoreUtils {
//SharedPreferences _sharedPreferences; //SharedPreferences _sharedPreferences;
/// 临时目录 eg: cookie /// 临时目录 eg: cookie
Directory _temporaryDirectory; Directory? _temporaryDirectory;
/// 初始化必备操作 eg:user数据 /// 初始化必备操作 eg:user数据
LocalStorage _localStorage; LocalStorage? _localStorage;
static StoreUtils _instance; static StoreUtils? _instance;
static StoreUtils getInstance() { static StoreUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new StoreUtils(); _instance = new StoreUtils();
} }
...@@ -34,15 +33,15 @@ class StoreUtils { ...@@ -34,15 +33,15 @@ class StoreUtils {
//_sharedPreferences = await SharedPreferences.getInstance(); //_sharedPreferences = await SharedPreferences.getInstance();
_localStorage = LocalStorage('LocalStorage'); _localStorage = LocalStorage('LocalStorage');
_temporaryDirectory = await getTemporaryDirectory(); _temporaryDirectory = await getTemporaryDirectory();
return await _localStorage.ready; return await _localStorage!.ready;
} }
/// ///
/// 根据[key]获取相应的值 /// 根据[key]获取相应的值
/// [key] 键 /// [key] 键
/// ///
dynamic getForKey({@required String key,dynamic defaultValue}) { dynamic getForKey({required String key,dynamic defaultValue}) {
return getStorage.getItem(key)??defaultValue; return getStorage!.getItem(key)??defaultValue;
} }
/// ///
...@@ -50,7 +49,7 @@ class StoreUtils { ...@@ -50,7 +49,7 @@ class StoreUtils {
/// [key] 键 /// [key] 键
/// [value] 值 /// [value] 值
/// ///
Future<void> setKV({@required String key, @required dynamic value}) { Future<void>? setKV({required String key, required dynamic value}) {
return getStorage?.setItem(key, value); return getStorage?.setItem(key, value);
} }
...@@ -58,14 +57,14 @@ class StoreUtils { ...@@ -58,14 +57,14 @@ class StoreUtils {
/// 根据[key]删除对应的值 /// 根据[key]删除对应的值
/// [key] 键 /// [key] 键
/// ///
Future<void> delForkey({@required String key}) { Future<void> delForkey({required String key}) {
return getStorage.deleteItem(key); return getStorage!.deleteItem(key);
} }
/// ///
/// 获取本地存储类 /// 获取本地存储类
/// ///
LocalStorage get getStorage { LocalStorage? get getStorage {
return _localStorage; return _localStorage;
} }
...@@ -79,7 +78,7 @@ class StoreUtils { ...@@ -79,7 +78,7 @@ class StoreUtils {
/// ///
/// 获取缓存的文件夹 /// 获取缓存的文件夹
/// ///
Directory get getTempDir { Directory? get getTempDir {
return _temporaryDirectory; return _temporaryDirectory;
} }
} }
import 'package:share_extend/share_extend.dart'; import 'package:share_extend/share_extend.dart';
class SystemShareUtils { class SystemShareUtils {
static SystemShareUtils instance; static SystemShareUtils? instance;
static SystemShareUtils getInstance() { static SystemShareUtils? getInstance() {
if (instance == null) { if (instance == null) {
instance = new SystemShareUtils(); instance = new SystemShareUtils();
} }
......
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart'; import 'package:umeng_common_sdk/umeng_common_sdk.dart';
import 'package:umeng_crash/umeng_crash.dart'; import 'package:umeng_crash/umeng_crash.dart';
/// 公司友盟Key /// 公司友盟Key
...@@ -75,7 +72,7 @@ class UmengUtils { ...@@ -75,7 +72,7 @@ class UmengUtils {
/// [e] 异常信息 /// [e] 异常信息
/// [type] 异常类型 /// [type] 异常类型
/// ///
static void generateCustomLog({@required String e,@required String type}){ static void generateCustomLog({required String e,required String type}){
UmengCrash.generateCustomLog(e: e, type: type); UmengCrash.generateCustomLog(e: e, type: type);
} }
......
...@@ -6,15 +6,15 @@ export 'package:fluwx/src/share/share_models.dart'; ...@@ -6,15 +6,15 @@ export 'package:fluwx/src/share/share_models.dart';
class WxSdkUtils { class WxSdkUtils {
// 唤起登录回调 // 唤起登录回调
static Function(wx.WeChatAuthResponse res) _sendWeChatAuthCallback; static Function(wx.WeChatAuthResponse res)? _sendWeChatAuthCallback;
// 唤起分享回调 // 唤起分享回调
static Function(wx.WeChatShareResponse res) _shareToWeChatCallback; static Function(wx.WeChatShareResponse res)? _shareToWeChatCallback;
// 唤起支付回调 // 唤起支付回调
static Function(wx.WeChatPaymentResponse res) _payWithWeChatCallback; static Function(wx.WeChatPaymentResponse res)? _payWithWeChatCallback;
// 唤起消息订阅回调 // 唤起消息订阅回调
static Function(wx.WeChatSubscribeMsgResponse res) static Function(wx.WeChatSubscribeMsgResponse res)?
_subscribeWeChatMsgCallback; _subscribeWeChatMsgCallback;
// 初始化 // 初始化
...@@ -22,22 +22,22 @@ class WxSdkUtils { ...@@ -22,22 +22,22 @@ class WxSdkUtils {
wx.weChatResponseEventHandler.listen((res) { wx.weChatResponseEventHandler.listen((res) {
if (res is wx.WeChatAuthResponse) { if (res is wx.WeChatAuthResponse) {
if (_sendWeChatAuthCallback != null) { if (_sendWeChatAuthCallback != null) {
_sendWeChatAuthCallback(res); _sendWeChatAuthCallback!(res);
_sendWeChatAuthCallback = null; _sendWeChatAuthCallback = null;
} }
} else if (res is wx.WeChatShareResponse) { } else if (res is wx.WeChatShareResponse) {
if (_shareToWeChatCallback != null) { if (_shareToWeChatCallback != null) {
_shareToWeChatCallback(res); _shareToWeChatCallback!(res);
_shareToWeChatCallback = null; _shareToWeChatCallback = null;
} }
} else if (res is wx.WeChatPaymentResponse) { } else if (res is wx.WeChatPaymentResponse) {
if (_payWithWeChatCallback != null) { if (_payWithWeChatCallback != null) {
_payWithWeChatCallback(res); _payWithWeChatCallback!(res);
_payWithWeChatCallback = null; _payWithWeChatCallback = null;
} }
} else if (res is wx.WeChatSubscribeMsgResponse) { } else if (res is wx.WeChatSubscribeMsgResponse) {
if (_subscribeWeChatMsgCallback != null) { if (_subscribeWeChatMsgCallback != null) {
_subscribeWeChatMsgCallback(res); _subscribeWeChatMsgCallback!(res);
_subscribeWeChatMsgCallback = null; _subscribeWeChatMsgCallback = null;
} }
} }
...@@ -48,7 +48,7 @@ class WxSdkUtils { ...@@ -48,7 +48,7 @@ class WxSdkUtils {
// 调起微信登录 // 调起微信登录
static Future<wx.WeChatAuthResponse> sendWeChatAuth({ static Future<wx.WeChatAuthResponse> sendWeChatAuth({
String scope = 'snsapi_userinfo', String scope = 'snsapi_userinfo',
String state, required String state,
}) { }) {
Completer<wx.WeChatAuthResponse> completer = Completer<wx.WeChatAuthResponse> completer =
new Completer<wx.WeChatAuthResponse>(); new Completer<wx.WeChatAuthResponse>();
...@@ -74,15 +74,15 @@ class WxSdkUtils { ...@@ -74,15 +74,15 @@ class WxSdkUtils {
// 微信支付 // 微信支付
static Future<wx.WeChatPaymentResponse> payWithWeChat( static Future<wx.WeChatPaymentResponse> payWithWeChat(
{@required String appId, {required String appId,
@required String partnerId, required String partnerId,
@required String prepayId, required String prepayId,
@required String packageValue, required String packageValue,
@required String nonceStr, required String nonceStr,
@required int timeStamp, required int timeStamp,
@required String sign, required String sign,
String signType, String? signType,
String extData}) { String? extData}) {
Completer<wx.WeChatPaymentResponse> completer = Completer<wx.WeChatPaymentResponse> completer =
new Completer<wx.WeChatPaymentResponse>(); new Completer<wx.WeChatPaymentResponse>();
_payWithWeChatCallback = (res) { _payWithWeChatCallback = (res) {
...@@ -104,10 +104,10 @@ class WxSdkUtils { ...@@ -104,10 +104,10 @@ class WxSdkUtils {
// 消息订阅 // 消息订阅
static Future<wx.WeChatSubscribeMsgResponse> subscribeWeChatMsg({ static Future<wx.WeChatSubscribeMsgResponse> subscribeWeChatMsg({
@required String appId, required String appId,
@required int scene, required int scene,
@required String templateId, required String templateId,
String reserved, String? reserved,
}) { }) {
Completer<wx.WeChatSubscribeMsgResponse> completer = Completer<wx.WeChatSubscribeMsgResponse> completer =
new Completer<wx.WeChatSubscribeMsgResponse>(); new Completer<wx.WeChatSubscribeMsgResponse>();
...@@ -135,7 +135,7 @@ class WxSdkUtils { ...@@ -135,7 +135,7 @@ class WxSdkUtils {
/// [path] 待打开的小程序路径 /// [path] 待打开的小程序路径
/// ///
static Future<bool> launchWeChatMiniProgram( static Future<bool> launchWeChatMiniProgram(
{@required String appId, String path}) async { {required String appId, String? path}) async {
return await wx.launchWeChatMiniProgram(username: appId, path: path); return await wx.launchWeChatMiniProgram(username: appId, path: path);
} }
} }
...@@ -14,36 +14,36 @@ import 'loading_dialog_utils.dart'; ...@@ -14,36 +14,36 @@ import 'loading_dialog_utils.dart';
import 'package:flutter_native_toast/flutter_native_toast.dart'; import 'package:flutter_native_toast/flutter_native_toast.dart';
class XAppUtils { class XAppUtils {
static XAppUtils _instance; static XAppUtils? _instance;
static XAppUtils getInstance() { static XAppUtils? getInstance() {
if (_instance == null) { if (_instance == null) {
_instance = new XAppUtils._(); _instance = new XAppUtils._();
} }
return _instance; return _instance;
} }
double _mediaWidth; double? _mediaWidth;
double _mediaHeight; double? _mediaHeight;
double _adaptWidth; double? _adaptWidth;
String _deviceId; String? _deviceId;
String _deviceType; String? _deviceType;
String _osVersion; String? _osVersion;
String _appVersion; String? _appVersion;
String _appBuildNumber; String? _appBuildNumber;
String _idfaID; String? _idfaID;
XAppUtils._(); XAppUtils._();
/// 初始化 /// 初始化
/// [context] 上下文 /// [context] 上下文
/// [uiWidth] UI尺寸宽度 /// [uiWidth] UI尺寸宽度
void init({@required BuildContext context, double uiWidth = 375}) async { void init({required BuildContext context, double uiWidth = 375}) async {
if (_adaptWidth == null || _adaptWidth == 0.0) { if (_adaptWidth == null || _adaptWidth == 0.0) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
_mediaWidth = size.width; _mediaWidth = size.width;
_mediaHeight = size.height; _mediaHeight = size.height;
_adaptWidth = _mediaWidth / uiWidth; _adaptWidth = _mediaWidth! / uiWidth;
if(_appVersion == null){ if(_appVersion == null){
var packageInfo = await PackageInfo.fromPlatform(); var packageInfo = await PackageInfo.fromPlatform();
_appBuildNumber = packageInfo.buildNumber; _appBuildNumber = packageInfo.buildNumber;
...@@ -53,25 +53,25 @@ class XAppUtils { ...@@ -53,25 +53,25 @@ class XAppUtils {
} }
/// 获取屏幕宽度 /// 获取屏幕宽度
double getMediaWidth() { double? getMediaWidth() {
return _mediaWidth; return _mediaWidth;
} }
/// 获取屏幕高度 /// 获取屏幕高度
double getMediaHeight() { double? getMediaHeight() {
return _mediaHeight; return _mediaHeight;
} }
double getAdaptWidth() { double? getAdaptWidth() {
return _adaptWidth; return _adaptWidth;
} }
/// 根据UI单位转换成rpx /// 根据UI单位转换成rpx
double rpx(num px) { double rpx(num px) {
return double.parse((px * getAdaptWidth()).toStringAsFixed(6)); return double.parse((px * getAdaptWidth()!).toStringAsFixed(6));
} }
LoadingDialog showLoading([String msg = '请稍后']) { LoadingDialog showLoading([String msg = '请稍后']) {
return LoadingDialogUtils.getInstance().show(msg: msg); return LoadingDialogUtils.getInstance()!.show(msg: msg);
} }
/// sha1编码 /// sha1编码
...@@ -95,7 +95,7 @@ class XAppUtils { ...@@ -95,7 +95,7 @@ class XAppUtils {
} }
/// 获取设备ID /// 获取设备ID
Future<String> getDeviceId() async { Future<String?> getDeviceId() async {
if (_deviceId == null) { if (_deviceId == null) {
if (Platform.isIOS) { if (Platform.isIOS) {
var info = await DeviceInfoPlugin().iosInfo; var info = await DeviceInfoPlugin().iosInfo;
...@@ -109,7 +109,7 @@ class XAppUtils { ...@@ -109,7 +109,7 @@ class XAppUtils {
} }
/// 获取设备类型,如: iPod7,1 /// 获取设备类型,如: iPod7,1
Future<String> getDeviceType() async { Future<String?> getDeviceType() async {
if (_deviceType == null) { if (_deviceType == null) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo; AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
...@@ -128,7 +128,7 @@ class XAppUtils { ...@@ -128,7 +128,7 @@ class XAppUtils {
} }
/// 获取系统版本号,如: 10 /// 获取系统版本号,如: 10
Future<String> getOsVersion() async { Future<String?> getOsVersion() async {
if (_osVersion == null) { if (_osVersion == null) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo; AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
...@@ -143,11 +143,11 @@ class XAppUtils { ...@@ -143,11 +143,11 @@ class XAppUtils {
} }
/// 获取app版本号,如: 1.0.0 /// 获取app版本号,如: 1.0.0
String getAppVersion() { String? getAppVersion() {
return _appVersion; return _appVersion;
} }
String getAppBuildNumber(){ String? getAppBuildNumber(){
return _appBuildNumber; return _appBuildNumber;
} }
...@@ -158,21 +158,21 @@ class XAppUtils { ...@@ -158,21 +158,21 @@ class XAppUtils {
/// 获取剪贴板内容 /// 获取剪贴板内容
Future<String> getClipboardText() async { Future<String> getClipboardText() async {
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
if (data == null) { if (data == null) {
return ''; return '';
} }
return data.text ?? ''; return data.text ?? '';
} }
Future<String> getIDFAID() async { Future<String?> getIDFAID() async {
if (_idfaID != null) { if (_idfaID != null) {
return _idfaID; return _idfaID;
} }
//读取存储的设备id,没有id就创建一个 //读取存储的设备id,没有id就创建一个
//设备唯一id //设备唯一id
_idfaID = await FlutterSecureStorage().read(key: 'kIDFAID'); _idfaID = await FlutterSecureStorage().read(key: 'kIDFAID');
if (_idfaID == null || _idfaID.contains('000000000000')) { if (_idfaID == null || _idfaID!.contains('000000000000')) {
if (Platform.isIOS) { if (Platform.isIOS) {
var info = await DeviceInfoPlugin().iosInfo; var info = await DeviceInfoPlugin().iosInfo;
// idfaID = await pangle.getIdfaString(); // idfaID = await pangle.getIdfaString();
...@@ -191,9 +191,9 @@ class XAppUtils { ...@@ -191,9 +191,9 @@ class XAppUtils {
} }
extension SizeExtension on num { extension SizeExtension on num {
double get rpx => XAppUtils.getInstance().rpx(this); double get rpx => XAppUtils.getInstance()!.rpx(this);
double get w => XAppUtils.getInstance().rpx(this); double get w => XAppUtils.getInstance()!.rpx(this);
double get nsp => XAppUtils.getInstance().rpx(this); double get nsp => XAppUtils.getInstance()!.rpx(this);
} }
Color rgba(int r, int g, int b, double a) => Color.fromRGBO(r, g, b, a); Color rgba(int r, int g, int b, double a) => Color.fromRGBO(r, g, b, a);
import 'package:flutter/material.dart';
import 'listener/ds_listener.dart'; import 'listener/ds_listener.dart';
class DSFrame { class DSFrame {
...@@ -10,14 +8,14 @@ class DSFrame { ...@@ -10,14 +8,14 @@ class DSFrame {
/// ///
/// 按键点击监听 /// 按键点击监听
/// ///
DSListener listener; DSListener? listener;
/// ///
/// build 初始化 /// build 初始化
/// listener 监听,监听按钮的点击事件 /// listener 监听,监听按钮的点击事件
/// ///
void build({ void build({
DSListener listener, DSListener? listener,
}){ }){
DSFrame.create.listener = listener; DSFrame.create.listener = listener;
} }
...@@ -25,9 +23,9 @@ class DSFrame { ...@@ -25,9 +23,9 @@ class DSFrame {
/// ///
/// 设置上报的数据监听 /// 设置上报的数据监听
/// ///
void dataListener({@required String id,String pageName,dynamic extras}){ void dataListener({required String id,String? pageName,dynamic extras}){
if(listener != null){ if(listener != null){
listener(id,pageName,extras); listener!(id,pageName,extras);
} }
} }
} }
...@@ -4,18 +4,18 @@ import 'package:flutter/material.dart'; ...@@ -4,18 +4,18 @@ import 'package:flutter/material.dart';
class CachedNetworkImage extends StatelessWidget { class CachedNetworkImage extends StatelessWidget {
final String imageUrl; final String imageUrl;
final Widget Function(BuildContext, String) placeholder; final Widget Function(BuildContext, String)? placeholder;
final Widget Function( final Widget Function(
BuildContext context, String url, Cache.DownloadProgress progress) BuildContext context, String url, Cache.DownloadProgress progress)?
progressIndicatorBuilder; progressIndicatorBuilder;
final double width; final double? width;
final double height; final double? height;
final BoxFit fit; final BoxFit? fit;
final Color color; final Color? color;
final AlignmentGeometry alignment; final AlignmentGeometry alignment;
const CachedNetworkImage( const CachedNetworkImage(
{Key key, {Key? key,
@required this.imageUrl, required this.imageUrl,
this.placeholder, this.placeholder,
this.progressIndicatorBuilder, this.progressIndicatorBuilder,
this.width, this.width,
...@@ -31,7 +31,7 @@ class CachedNetworkImage extends StatelessWidget { ...@@ -31,7 +31,7 @@ class CachedNetworkImage extends StatelessWidget {
var data = MediaQuery.of(context); var data = MediaQuery.of(context);
var devicePixelRatio = data.devicePixelRatio; var devicePixelRatio = data.devicePixelRatio;
return Cache.CachedNetworkImage( return Cache.CachedNetworkImage(
alignment: alignment, alignment: alignment as Alignment,
imageUrl: imageUrl, imageUrl: imageUrl,
placeholder: placeholder, placeholder: placeholder,
width: width, width: width,
...@@ -50,17 +50,17 @@ class CachedNetworkImage extends StatelessWidget { ...@@ -50,17 +50,17 @@ class CachedNetworkImage extends StatelessWidget {
); );
} }
int getDiskCacheSize({double size, double devicePixelRatio}) { int? getDiskCacheSize({double? size, double? devicePixelRatio}) {
if (size == null || size == double.infinity) { if (size == null || size == double.infinity) {
return null; return null;
} }
return (size * devicePixelRatio).toInt(); return (size * devicePixelRatio!).toInt();
} }
int getMemCacheSize({@required double size, double devicePixelRatio}) { int? getMemCacheSize({required double? size, double? devicePixelRatio}) {
if (size == null || size == double.infinity) { if (size == null || size == double.infinity) {
return null; return null;
} }
return (size * devicePixelRatio).toInt(); return (size * devicePixelRatio!).toInt();
} }
} }
...@@ -2,23 +2,23 @@ import 'package:common_module/widget/ds_frame.dart'; ...@@ -2,23 +2,23 @@ import 'package:common_module/widget/ds_frame.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_boost/boost_navigator.dart'; import 'package:flutter_boost/boost_navigator.dart';
typedef DSListener = void Function(String id, String pageName,Map<String,dynamic> extras); typedef DSListener = void Function(String? id, String? pageName,Map<String,dynamic>? extras);
class DSWidgetListener extends StatelessWidget { class DSWidgetListener extends StatelessWidget {
final Widget child; //包裹的布局 final Widget child; //包裹的布局
final String id; //按键的id值,用于区分点击的按键 final String? id; //按键的id值,用于区分点击的按键
final dynamic extras; //附加参数 final dynamic extras; //附加参数
const DSWidgetListener({Key key, @required this.child, this.id,this.extras = const {}}) : super(key: key); const DSWidgetListener({Key? key, required this.child, this.id,this.extras = const {}}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Listener( return Listener(
child: child, child: child,
onPointerDown: (e) { onPointerDown: (e) {
PageInfo pageInfo = BoostNavigator.instance.getTopPageInfo(); PageInfo? pageInfo = BoostNavigator.instance.getTopPageInfo();
if (DSFrame.create.listener != null) { if (DSFrame.create.listener != null) {
DSFrame.create.listener(id,pageInfo?.pageName??'',extras); DSFrame.create.listener!(id,pageInfo?.pageName??'',extras);
} }
}, },
onPointerCancel:(e){ onPointerCancel:(e){
......
...@@ -3,13 +3,13 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; ...@@ -3,13 +3,13 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
export 'package:pull_to_refresh/pull_to_refresh.dart'; export '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 Widget footer; final Widget? footer;
final int headerInsertIndex; final int headerInsertIndex;
final RefreshController controller; final RefreshController? controller;
final ScrollController scrollController; final ScrollController? scrollController;
PullWidget( PullWidget(
{this.child, {this.child,
...@@ -28,7 +28,7 @@ class PullWidget extends StatelessWidget { ...@@ -28,7 +28,7 @@ class PullWidget extends StatelessWidget {
//headerInsertIndex: headerInsertIndex, //headerInsertIndex: headerInsertIndex,
footer: footer, footer: footer,
scrollController: scrollController, scrollController: scrollController,
controller: controller, controller: controller!,
enablePullDown: onRefresh != null, enablePullDown: onRefresh != null,
enablePullUp: onLoad != null, enablePullUp: onLoad != null,
onRefresh: onRefresh, onRefresh: onRefresh,
......
...@@ -3,13 +3,13 @@ import 'package:common_module/utils/xapp_utils.dart'; ...@@ -3,13 +3,13 @@ import 'package:common_module/utils/xapp_utils.dart';
import 'package:mvp/mvp.dart'; import 'package:mvp/mvp.dart';
class ScrollToTopWidget extends StatelessWidget { class ScrollToTopWidget extends StatelessWidget {
final ScrollToModel model; final ScrollToModel? model;
const ScrollToTopWidget({Key key, this.model}) : super(key: key); const ScrollToTopWidget({Key? key, this.model}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return QMProvider<ScrollToModel>.value( return QMProvider<ScrollToModel>.value(
model: model, model: model!,
builderWidget: (context, model, child) => Offstage( builderWidget: (context, model, child) => Offstage(
offstage: !model.showFloatingButton, offstage: !model.showFloatingButton,
child: Container( child: Container(
......
...@@ -3,15 +3,15 @@ import 'package:flutter/cupertino.dart'; ...@@ -3,15 +3,15 @@ import 'package:flutter/cupertino.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class TapWidget extends StatelessWidget { class TapWidget extends StatelessWidget {
final Widget child; final Widget child;
final GestureTapCallback onTap; final GestureTapCallback? onTap;
final Function onLongPress; final Function? onLongPress;
final HitTestBehavior behavior; final HitTestBehavior behavior;
int lastTapTime = 0; int lastTapTime = 0;
TapWidget( TapWidget(
{@required this.child, {required this.child,
this.onTap, this.onTap,
Key key, Key? key,
this.behavior = HitTestBehavior.translucent, this.behavior = HitTestBehavior.translucent,
this.onLongPress}) this.onLongPress})
: super(key: key) { : super(key: key) {
...@@ -23,7 +23,7 @@ class TapWidget extends StatelessWidget { ...@@ -23,7 +23,7 @@ class TapWidget extends StatelessWidget {
return GestureDetector( return GestureDetector(
behavior: behavior, behavior: behavior,
child: child, child: child,
onLongPress: onLongPress, onLongPress: onLongPress as void Function()?,
onTap: () { onTap: () {
if (this.onTap != null) { if (this.onTap != null) {
int now = DateTime.now().millisecondsSinceEpoch; int now = DateTime.now().millisecondsSinceEpoch;
...@@ -32,7 +32,7 @@ class TapWidget extends StatelessWidget { ...@@ -32,7 +32,7 @@ class TapWidget extends StatelessWidget {
} }
lastTapTime = now; lastTapTime = now;
this.onTap(); this.onTap!();
} }
}, },
); );
......
...@@ -13,14 +13,14 @@ var isCache = RegExp(r'_\d+x\d+((Q\d+s\d+)?).(jpg|png|gif|jpeg)'); ...@@ -13,14 +13,14 @@ var isCache = RegExp(r'_\d+x\d+((Q\d+s\d+)?).(jpg|png|gif|jpeg)');
///[placeholderFit]占位适应方式[BoxFit] ///[placeholderFit]占位适应方式[BoxFit]
class XiaoxiongBaseImageWidget extends StatelessWidget { class XiaoxiongBaseImageWidget extends StatelessWidget {
final String imageUrl; final String imageUrl;
final String heroTag; final String? heroTag;
final String progressImage; final String? progressImage;
final BoxFit fit; final BoxFit fit;
final double width; final double? width;
final double height; final double? height;
final BoxFit placeholderFit; final BoxFit placeholderFit;
final AlignmentGeometry alignment; final AlignmentGeometry alignment;
final Widget Function(BuildContext, String) placeholder; final Widget Function(BuildContext, String)? placeholder;
String get _imageUrl { String get _imageUrl {
// var isAli = isAliCDN.hasMatch(imageUrl); // var isAli = isAliCDN.hasMatch(imageUrl);
...@@ -33,8 +33,8 @@ class XiaoxiongBaseImageWidget extends StatelessWidget { ...@@ -33,8 +33,8 @@ class XiaoxiongBaseImageWidget extends StatelessWidget {
} }
const XiaoxiongBaseImageWidget( const XiaoxiongBaseImageWidget(
{Key key, {Key? key,
@required this.imageUrl, required this.imageUrl,
this.progressImage, this.progressImage,
this.fit = BoxFit.cover, this.fit = BoxFit.cover,
this.width, this.width,
...@@ -47,8 +47,8 @@ class XiaoxiongBaseImageWidget extends StatelessWidget { ...@@ -47,8 +47,8 @@ class XiaoxiongBaseImageWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (heroTag != null && heroTag.isNotEmpty) { if (heroTag != null && heroTag!.isNotEmpty) {
return Hero(tag: heroTag, child: buildCachedNetworkImage()); return Hero(tag: heroTag!, child: buildCachedNetworkImage());
} }
return Container( return Container(
child: buildCachedNetworkImage(), child: buildCachedNetworkImage(),
...@@ -56,7 +56,7 @@ class XiaoxiongBaseImageWidget extends StatelessWidget { ...@@ -56,7 +56,7 @@ class XiaoxiongBaseImageWidget extends StatelessWidget {
} }
Widget buildCachedNetworkImage() { Widget buildCachedNetworkImage() {
if (imageUrl == null || imageUrl.isEmpty) { if (imageUrl.isEmpty) {
return Container( return Container(
width: width, width: width,
height: height, height: height,
...@@ -71,7 +71,7 @@ class XiaoxiongBaseImageWidget extends StatelessWidget { ...@@ -71,7 +71,7 @@ class XiaoxiongBaseImageWidget extends StatelessWidget {
} }
return CachedNetworkImage( return CachedNetworkImage(
alignment: alignment, alignment: alignment,
imageUrl: _imageUrl ?? '', imageUrl: _imageUrl,
fit: fit, fit: fit,
width: width, width: width,
height: height, height: height,
......
name: common_module name: common_module
description: A new Flutter package project. description: A new Flutter package project.
version: 0.0.1 version: 1.0.0
homepage: / 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" flutter: ">=1.17.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