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