utils/export
library
Classes
AdaptUtil
Bindings
Bindings should be extended or implemented.
When using GetMaterialApp
, all GetPage
s and navigation
methods (like Get.to()) have a binding
property that takes an
instance of Bindings to manage the
dependencies() (via Get.put()) for the Route you are opening.
BindingsBuilder <T >
Simplifies Bindings generation from a single callback.
To avoid the creation of a custom Binding instance per route.
Config
CustomTransition
DeviceInfoUtil
DisposableInterface
EasyLogController
EasyLogPage
FastList <T >
FormData
FullLifeCycleController
GetBar
GetBuilder <T extends GetxController >
GetBuilderState <T extends GetxController >
GetConnect
GetConnectInterface
GetCupertinoApp
GetDelegate
GetHttpClient
GetInformationParser
GetInstance
GetInterface
GetInterface allows any auxiliary package to be merged into the "Get"
class through extensions
GetLifeCycle
GetMaterialApp
GetMaterialController
GetMicrotask
GetMiddleware
The Page Middlewares.
The Functions will be called in this order
(( redirect -> onPageCalled -> onBindingsStart ->
onPageBuildStart -> onPageBuilt -> onPageDispose ))
GetModalBottomSheetRoute <T >
GetNavConfig
This config enables us to navigate directly to a sub-url
GetNavigator
GetNotifier <T >
GetObserver
GetPage <T >
GetPlatform
GetQueue
GetResponsiveView <T >
Extend this widget to build responsive view.
this widget contains the screen
property that have all
information about the screen size and type.
You have two options to build it.
1- with builder
method you return the widget to build.
2- with methods desktop
, tablet
,phone
, watch
. the specific
method will be built when the screen type matches the method
when the screen is ScreenType.Tablet the tablet
method
will be exuded and so on.
Note if you use this method please set the
property alwaysUseBuilder
to false
With settings
property you can set the width limit for the screen types.
GetResponsiveWidget <T extends GetLifeCycleBase ? >
GetRouterOutlet
GetSnackBar
GetSnackBarState
GetSocket
GetStream <T >
GetStream is the lightest and most performative way of working
with events at Dart. You sintaxe is like StreamController, but it works
with simple callbacks. In this way, every event calls only one function.
There is no buffering, to very low memory consumption.
event add will add a object to stream. addError will add a error
to stream. listen is a very light StreamSubscription interface.
Is possible take the last value with value property.
GetStreamTransformation <T >
GetUtils
GetView <T >
GetView is a great way of quickly access your Controller
without having to call Get.find
GetWidget <S extends GetLifeCycleBase ? >
GetWidget is a great way of quickly access your individual Controller
without having to call Get.find
GetX <T extends DisposableInterface >
GetxController
GetxService
Unlike GetxController, which serves to control events on each of its pages,
GetxService is not automatically disposed (nor can be removed with
Get.delete()).
It is ideal for situations where, once started, that service will
remain in memory, such as Auth control for example. Only way to remove
it is Get.reset().
GetXState <T extends DisposableInterface >
GraphQLResponse <T >
InstanceInfo
InternalFinalCallback <T >
Special callable class to keep the contract of a regular method, and avoid
overrides if you extend the class that uses it, as Dart has no final
methods.
Used in DisposableInterface
to avoid the danger of overriding onStart.
IntlUtil
LightSubscription <T >
LogFile
LogFileClearMode
LoggerLevel
MiddlewareRunner
MiniStream <T >
MiniSubscription <T >
MixinBuilder <T extends GetxController >
MultipartFile
NetworkUtil
Node <T >
Obx
The simplest reactive widget in GetX.
ObxState
ObxValue <T extends RxInterface >
Similar to Obx, but manages a local state.
Pass the initial data in constructor.
Useful for simple local states, like toggles, visibility, themes,
button states, etc.
Sample:
ObxValue((data) => Switch(
value: data.value,
onChanged: (flag) => data.value = flag,
),
false.obs,
),
ObxWidget
The ObxWidget is the base for all GetX reactive widgets
PackageInfoUtil
PathDecoded
Response <T >
ResponsiveScreen
ResponsiveScreenSettings
Result
A Result.
RouterOutlet <TDelegate extends RouterDelegate <T > , T extends Object >
RouterOutletState <TDelegate extends RouterDelegate <T > , T extends Object >
Routing
Rx <T >
Foundation class used for custom Types
outside the common native Dart
types.
For example, any custom "Model" class, like User().obs will use Rx
as
wrapper.
RxBool
RxController
RxDouble
RxInt
RxInterface <T >
This class is the foundation for all reactive (Rx) classes that makes Get
so powerful.
This interface is the contract that _RxImpl]
RxList <E >
Create a list similar to List<T>
RxMap <K , V >
Rxn <T >
RxnBool
RxnDouble
RxnInt
RxnNum
RxNotifier <T >
RxnString
Rx class for String
Type.
RxNum
RxSet <E >
RxStatus
RxString
Rx class for String
Type.
Session
SharedPreferencesUtil
SimpleBuilder
SimpleBuilderState
SnackbarController
StorageUtil
SuperController <T >
TimerUtil
Translations
TrustedCertificate
Value <T >
ValueBuilder <T >
Manages a local state like ObxValue, but uses a callback instead of
a Rx value.
ValueBuilderState <T >
Worker
Workers
Enums
BaseURLType
URL环境
PopMode
Enables the user to customize the intended pop behavior
PreventDuplicateHandlingMode
Enables the user to customize the behavior when pushing multiple routes that
shouldn't be duplicates
RowStyle
ScreenType
SmartManagement
GetX by default disposes unused controllers from memory,
Through different behaviors.
SmartManagement.full
SmartManagement.full is the default one. Dispose classes that are
not being used and were not set to be permanent. In the majority
of the cases you will want to keep this config untouched.
If you new to GetX then don't change this.
SmartManagement.onlyBuilder only controllers started in init:
or loaded into a Binding with Get.lazyPut() will be disposed. If you use
Get.put() or Get.putAsync() or any other approach, SmartManagement
will not have permissions to exclude this dependency. With the default
behavior, even widgets instantiated with "Get.put" will be removed,
unlike SmartManagement.onlyBuilders.
SmartManagement.keepFactory Just like SmartManagement.full,
it will remove it's dependencies when it's not being used anymore.
However, it will keep their factory, which means it will recreate
the dependency if you need that instance again.
SnackbarStatus
Indicates Status of snackbar
SnackbarStatus.OPEN Snack is fully open, SnackbarStatus.CLOSED Snackbar
has closed,
SnackbarStatus.OPENING Starts with the opening animation and ends
with the full
snackbar display, SnackbarStatus.CLOSING Starts with the closing animation
and ends
with the full snackbar dispose
SnackPosition
Indicates if snack is going to start at the TOP or at the BOTTOM
SnackStyle
Indicates if snack will be attached to the edge of the screen or not
Transition
Functions
adaptDp (dynamic number )
→ dynamic
根据设计稿的比例适配dp保证不变形
adaptOnePx ()
→ dynamic
根据设备适配1px像素大小
adaptPx (dynamic number )
→ dynamic
根据设计稿的比例适配像素保证不变形
ambiguate <T > (T? value )
→ T?
appDarkMode (BuildContext context )
→ bool
appStoreUrl (String appId )
→ String
appStoreUserReviewsUrl (String appId )
→ String
appStoreWriteReview (String appId )
→ String
appTheme (BuildContext context )
→ ThemeData
appUpdateLocale (Locale l )
→ void
assetsImagesPath (String name , {String format = "png" })
→ String
获取图片路径
assetsImagesPathSvg (String name )
→ String
获取图片路径后缀svg
assetsImagesPathWebP (String name )
→ String
获取图片路径后缀wep
base64Decode (String encoded )
→ Uint8List ?
base64解密字符串
base64DecodeString (String data )
→ String
base64解密字符串
base64Encode (List <int > input )
→ String
base64加密二进制
base64EncodeString (String data )
→ String
base64加密字符串
bodyBytesToString (Stream <List <int > > bodyBytes , Map <String , String > headers )
→ Future <String >
calcTemporaryDirectoryCacheSize ()
→ Future <String >
canLaunch (String urlString )
→ Future <bool >
checkConnectivity ()
→ Future <List <BaseConnectivityResult > >
checkVersion (String action , String baseUrl )
→ dynamic
clearShareDirectory ()
→ Future <void >
clearStorage ()
→ Future <bool >
clearTemporaryDirectoryCache ()
→ Future <bool >
colorWithRandom ()
→ Color
convertImageToJpg ({required File inputFile , int quality = 100 , JpegChroma chroma = JpegChroma.yuv444 })
→ Future <Uint8List ? >
to the JPEG format.
debounce <T > (RxInterface <T > listener , WorkerCallback <T > callback , {Duration ? time , Function ? onError , void onDone ()?, bool ? cancelOnError })
→ Worker
debounce is similar to interval , but sends the last value.
Useful for Anti DDos, every time the user stops typing for 1 second,
for instance.
When listener
emits the last "value", when time
hits,
it calls callback
with the last "value" emitted.
decryptString (String string )
→ String
defaultLogWriterCallback (String value , {bool isError = false })
→ void
default logger from GetX
delete ({String ? baseUrl , String path = '' , dynamic data , Map <String , dynamic > ? queryParameters , Duration ? connectTimeout , BaseCancelToken ? cancelToken , ProgressCallback? onSendProgress , ProgressCallback? onReceiveProgress , bool validResult = true , bool autoLoading = false })
→ Future <Result >
发送DELETE请求并解析远程服务器返回的result对应的实体类型
dismissLoading ()
→ void
downloadFile ({required String url , String ? savePath , bool loading = true })
→ Future <String ? >
encryptString (String string )
→ String
ever <T > (RxInterface <T > listener , WorkerCallback <T > callback , {dynamic condition = true , Function ? onError , void onDone ()?, bool ? cancelOnError })
→ Worker
Called every time listener
changes. As long as the condition
returns true.
everAll (List <RxInterface > listeners , WorkerCallback callback , {dynamic condition = true , Function ? onError , void onDone ()?, bool ? cancelOnError })
→ Worker
Similar to ever , but takes a list of listeners
, the condition
for the callback
is common to all listeners
,
and the callback
is executed to each one of them. The Worker is
common to all, so worker.dispose()
will cancel all streams.
formatDigitNum (Object num , {int digit = 3 })
→ String
每隔n位 加逗号
formatDigitPattern (String text , {int digit = 4 , String pattern = ' ' })
→ String
每隔n位 加 pattern
formatDigitPatternEnd (String text , {int digit = 4 , String pattern = ' ' })
→ String
每隔n位 加 pattern, 从末尾开始
formatFractionDigitsAsFixed (double amount , {int fractionDigits = 2 , bool autoClearZero = false })
→ String
保留n位小数
get ({String ? baseUrl , String path = '' , Map <String , dynamic > ? queryParameters , Duration ? connectTimeout , BaseCancelToken ? cancelToken , bool validResult = true , bool autoLoading = false })
→ Future <Result >
发送GET请求并解析远程服务器返回的result对应的实体类型
getAppDocumentsDirectory ()
→ Future <Directory >
放置数据的目录的路径
getAppExternalStorageDirectory ()
→ Future <Directory ? >
应用程序可以访问顶级存储的目录的路径 Android
getAppLibraryDirectory ()
→ Future <Directory >
应用程序可以存储持久文件的目录的路径 iOS and macOS
getAppSupportDirectory ()
→ Future <Directory >
应用程序可以放置应用程序支持的目录的路径
getAppTemporaryDirectory ()
→ Future <Directory >
设备上临时目录的路径,该临时目录未备份且。适用于存储下载文件的缓存
getBasename (String path )
→ String
Gets the part of path
after the last separator.
getBasenameWithoutExtension (String path )
→ String
Gets the part of path
after the last separator, and without any trailing
file extension.
getClipboard ()
→ Future <String ? >
获取剪贴板内容
getDirname (String path )
→ String
Gets the part of path
before the last separator.
getExtension (String path , [int level = 1 ])
→ String
Gets the file extension of path
: the portion of basename
from the last
.
to the end (including the .
itself).
getJoin (String part1 , [String ? part2 , String ? part3 , String ? part4 , String ? part5 , String ? part6 , String ? part7 , String ? part8 , String ? part9 , String ? part10 , String ? part11 , String ? part12 , String ? part13 , String ? part14 , String ? part15 , String ? part16 ])
→ String
Joins the given path parts into a single path using the current platform's
separator
. Example:
getShareDirectory ()
→ Future <Directory >
getShareDirectoryPath ()
→ Future <String >
getStorageBool (String key )
→ Future <bool >
getStorageList (String key , {required String listKey , required dynamic onModels (Map <String , dynamic > json ) })
→ Future <List >
var models = await getStorageList(_orderNoKey, listKey: _orderNoForUserKey,
onModels: (json) {
return BaseKeyValue.fromJson(json);
});
getStorageMap (String key )
→ Future <Map <String , dynamic > ? >
getStorageString (String key )
→ Future <String ? >
getTheme ({bool darkMode = false , required bool useMaterial3 })
→ ThemeData
getUuidV1 ()
→ dynamic
基于时间戳实现
getUuidV4 ()
→ dynamic
基于随机算法实现
hapticFeedbackHeavyImpact ()
→ void
较重碰撞振动
hapticFeedbackLightImpact ()
→ void
较轻碰撞振动
hapticFeedbackMediumImpact ()
→ void
中等碰撞振动
hapticFeedbackVibrate ()
→ void
长振动
hideKeyboard (BuildContext context )
→ void
全局隐藏键盘
imageIsJpeg (File file )
→ Future <bool >
initSelectedBaseURLType ()
→ Future <String ? >
interval <T > (RxInterface <T > listener , WorkerCallback <T > callback , {Duration time = const Duration(seconds: 1) , dynamic condition = true , Function ? onError , void onDone ()?, bool ? cancelOnError })
→ Worker
Ignore all changes in listener
during time
(1 sec by default) or until
condition
is met (can be a bool expression or a bool Function()
),
It brings the 1st "value" since the period of time, so
if you click a counter button 3 times in 1 sec, it will show you "1"
(after 1 sec of the first press)
click counter 3 times in 1 sec, it will show you "4" (after 1 sec)
click counter 2 times in 1 sec, it will show you "7" (after 1 sec).
jsonDecode (String source , {Object ? reviver (Object ? key , Object ? value )? })
→ dynamic
Parses the string and returns the resulting Json object.
jsonEncode (Object ? value , {Object ? toEncodable (dynamic object )? })
→ String
Converts value
to a JSON string.
logDebug (dynamic message )
→ void
logError (dynamic message )
→ void
logFatal (dynamic message )
→ void
logInfo (dynamic message )
→ void
logRequest (RequestOptions options )
→ void
logResponse (Result result )
→ void
logWarning (dynamic message )
→ void
lunarSolarConverter (DateTime date )
→ Lunar
公历转农历
once <T > (RxInterface <T > listener , WorkerCallback <T > callback , {dynamic condition = true , Function ? onError , void onDone ()?, bool ? cancelOnError })
→ Worker
once()
will execute only 1 time when condition
is met and cancel
the subscription to the listener
stream right after that.
condition
defines when callback
is called, and
can be a bool or a bool Function()
.
onConnectivityChanged ()
→ Stream <List <BaseConnectivityResult > >
onLaunch (String urlString , {BaseLaunchMode mode = BaseLaunchMode.platformDefault , WebViewConfiguration webViewConfiguration = const urlLauncher.WebViewConfiguration() , String ? webOnlyWindowName })
→ Future <bool >
post ({String ? baseUrl , String path = '' , dynamic data , Map <String , dynamic > ? queryParameters , Duration ? connectTimeout , BaseCancelToken ? cancelToken , ProgressCallback? onSendProgress , ProgressCallback? onReceiveProgress , bool validResult = true , bool autoLoading = false })
→ Future <Result >
发送POST请求并解析远程服务器返回的result对应的实体类型
put ({String ? baseUrl , String path = '' , dynamic data , Map <String , dynamic > ? queryParameters , Duration ? connectTimeout , BaseCancelToken ? cancelToken , ProgressCallback? onSendProgress , ProgressCallback? onReceiveProgress , bool validResult = true , bool autoLoading = false })
→ Future <Result >
发送PUT请求并解析远程服务器返回的result对应的实体类型
randomInt (int max )
→ int
随机数(0-max)小于max
removeStorage (String key )
→ Future <bool >
request ({String ? baseUrl , String path = '' , dynamic data , Map <String , dynamic > ? queryParameters , BaseCancelToken ? cancelToken , Options? options , Duration ? connectTimeout , ProgressCallback? onSendProgress , ProgressCallback? onReceiveProgress , bool validResult = true , bool autoLoading = false })
→ Future <Result >
发送请求并解析远程服务器返回的result对应的实体类型
reverse (String text )
→ String
反转字符串
saveBaseURLType (BaseURLType urlType )
→ Future <bool >
保存选择的环境
setClipboard (String text )
→ Future <void >
将文本内容复制到剪贴板
setStorageBool (String key , bool value )
→ Future <bool >
setStorageList (String key , {required String listKey , required List list })
→ Future <bool >
var models = await getStorageList(_orderNoKey, listKey: _orderNoForUserKey,
onModels: (json) {
return BaseKeyValue.fromJson(json);
});
models.add(BaseKeyValue(key: "key", value: "${randomInt(100)}"));
await setStorageList(_orderNoKey, listKey: _orderNoForUserKey, list: models);
setStorageMap (String key , Map <String , dynamic > value )
→ Future <bool >
setStorageString (String key , String value )
→ Future <bool >
shareApp ()
→ Future <ShareResult >
shareFile ({required String url , String ? savePath })
→ Future <void >
shareText (String text , {String ? subject })
→ Future <ShareResult >
shareURL (String url )
→ Future <ShareResult >
showErrorToast (String status , {Duration ? duration , EasyLoadingMaskType? maskType , bool ? dismissOnTap })
→ void
showInfoToast (String status , {Duration ? duration , EasyLoadingMaskType? maskType , bool ? dismissOnTap })
→ void
showLoading ({String ? status , Widget ? indicator , EasyLoadingMaskType? maskType , bool ? dismissOnTap })
→ void
showProgress (double value , {String ? status , EasyLoadingMaskType? maskType })
→ void
showSelectBaseURLTypeAlert ({BuildContext ? context })
→ Future <bool ? >
弹出切换环境菜单
showSuccessToast (String status , {Duration ? duration , EasyLoadingMaskType? maskType , bool ? dismissOnTap })
→ void
showToast (String status , {Duration ? duration , EasyLoadingToastPosition? toastPosition , EasyLoadingMaskType? maskType , bool ? dismissOnTap })
→ void
sortMap (Map map )
→ Map
timestampBy (DateTime dateTime )
→ int
获取指定时间戳
timestampNow ()
→ int
获取当前时间戳
timestampTo_HH_mm (int timestamp , {String unit = ':' , bool isUtc = false })
→ String
时间戳转HH:mm
timestampToDateTime (int timestamp , {bool isUtc = false })
→ DateTime
时间戳转DateTime
timestampToNormal_yyyy_MM_dd (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy-MM-dd
timestampToNormal_yyyy_MM_dd_HH_mm_ss (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy-MM-dd HH:mm:ss
timestampToZh_yyyy_MM (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy年MM月
timestampToZh_yyyy_MM_dd (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy年MM月dd日
timestampToZh_yyyy_MM_dd_HH_mm (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy年MM月dd日 HH时mm分
timestampToZh_yyyy_MM_dd_HH_mm_ss (int timestamp , {bool isUtc = false })
→ String
时间戳转yyyy年MM月dd日 HH时mm分ss秒
twelveConstellationBy (DateTime dateTime )
→ BaseKeyValue
标志 星座 拉丁名称 出生日期(公历) 别名
♈
白羊座
Aries
3月21日~4月19日
牡羊座
♉
金牛座
Taurus
4月20日~5月20日
金牛座
♊
双子座
Gemini
5月21日~6月21日
双子座
♋
巨蟹座
Cancer
6月22日~7月22日
巨蟹座
♌
狮子座
Leo
7月23日~8月22日
狮子座
♍
处女座
Virgo
8月23日~9月22日
室女座
♎
天秤座
Libra
9月23日~10月23日
天平座
♏
天蝎座
Scorpio
10月24日~11月22日
天蝎座
♐
射手座
Sagittarius
11月23日~12月21日
人马座
♑
摩羯座
Capricorn
12月22日~1月19日
山羊座
♒
水瓶座
Aquarius
1月20日~2月18日
宝瓶座
♓
双鱼座
Pisces
2月19日~3月20日
双鱼座
"${(constellation.extend as List
twelveConstellationNow ()
→ BaseKeyValue
twoDigits (int n )
→ String
不足两位前面补0
uploadOSSFile ({required String filepath , required String policy , required String accessKeyId , required String signature , required String key , required String host , String successActionStatus = "204" , Duration connectTimeout = const Duration(seconds: 60) , BaseCancelToken ? cancelToken , ProgressCallback? onSendProgress })
→ Future <Result >
上传文件