base_lib_pub
library
Functions
-
baseBeforeRun()
→ Future<void>
-
-
checkPermission({required Permission permission, OnPermissionCheck? onPermissionCheck})
→ Future<bool>
-
-
checkStoragePermission({OnPermissionCheck? onPermissionCheck})
→ Future<bool>
-
-
clearAllGetxControllers()
→ void
-
清除所有getx控制器
-
clearExtendedImageCache()
→ Future<bool>
-
清除ExtendedImage缓存
-
clickBack({dynamic result})
→ Future<bool>
-
点击返回
-
compareYMD(DateTime d1, DateTime d2)
→ bool
-
比较年月日
-
compressAndGetImageFile({required File imageFile, required String targetPath, int maxSize = imgMaxSizeByByte})
→ Future<File?>
-
压缩图片
-
compressAndGetImageFilePath({required String imageFilePath, required String targetPath, int maxSize = imgMaxSizeByByte})
→ Future<String>
-
压缩图片
-
createDir(String path)
→ void
-
创建文件夹
-
createFile(String path)
→ void
-
创建文件
-
createImgName()
→ String
-
-
deleteDirOrFile(String path)
→ void
-
删除文件夹及其内部文件
-
doDelay(int milliSec, VoidCallback callback)
→ void
-
Name: common_utils.dart
-
doDelayOn(Duration delay, VoidCallback callback)
→ void
-
延迟执行
-
doInterval(Duration interval, void callback(Timer? timer), {bool callOnStart = false})
→ Timer
-
定时循环执行
-
e({required dynamic msg, String tag = '', bool split = false, String? ansiColor})
→ void
-
打印错误日志
-
exitApp({bool force = false})
→ void
-
退出APP
-
formatIntMoney(int num)
→ String
-
货币格式
-
formatMoney(double num)
→ String
-
货币格式
-
get<T>(String path, {Map<String, dynamic>? params, String? contentType, ResponseType? responseType, CancelToken? cancelToken, Options? options, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, Duration? sendTimeout, Duration? receiveTimeout})
→ Future<Response<T>>
-
get请求
-
getAssetPath(String name, {String type = "png", String dir = '/'})
→ String
-
通过assets资源路径
-
getBaseAssetPath(String name, {String type = "", String dir = ''})
→ String
-
通过名称拼接assets base_lib_pub路径
-
getBaseImagePath(String imgName, {String type = "png"})
→ String
-
通过名称拼接assets base_lib_pub图片路径
-
getBytes(String path)
→ List
-
-
getFileContent(String path)
→ MultipartFile
-
获取文件内容
-
getImagePath(String imgName, {String type = "png", String dir = 'images/'})
→ String
-
通过名称拼接assets图片路径
-
getLastDirInPath(String path)
→ String
-
从路径中获取文件名
-
getNameInPath(String path)
→ String
-
从路径中获取文件名
-
getRenderImage(GlobalKey<State<StatefulWidget>> gk)
→ Future<Image?>
-
-
getRowCount(int length, int lengthPerRow)
→ int
-
计算行数
-
getScreenHeight(BuildContext context)
→ double
-
获取屏幕高度
-
getScreenSize(BuildContext context)
→ Size
-
获取屏幕尺寸
-
getScreenWidth(BuildContext context)
→ double
-
获取屏幕宽度
-
getStatusBarHeight(BuildContext context)
→ double
-
获取状态栏高度
-
getSystemOverlayStyle({Color? statusBarColor, bool? isStatusBarIconLight, Color? sysNavigationBarColor, bool? isSysNavigationBarIconLight})
→ SystemUiOverlayStyle
-
获得状态栏、系统导航栏样式(默认深底白字、黑底白字)
-
hideKeyboard()
→ void
-
隐藏软键盘
-
i({required dynamic msg, String tag = '', bool split = false, String? ansiColor})
→ void
-
打印信息日志
-
initCrashHandler({String? prefixMsg, dynamic toastError = false})
→ void
-
Name: crash_utils.dart
-
initDio({String baseUrl = '', Duration connectTimeout = const Duration(seconds: 10), Duration? receiveTimeout = const Duration(seconds: 30), bool isAddLogInterceptor = true, bool ignoreCertificate = false, bool isClientGlobal = true, String? certPem, bool verifyCallback(X509Certificate cert, String host, int port)?})
→ void
-
配置dio
-
initHttpClient({bool ignoreCertificate = false, String? certPem, bool isClientGlobal = false, bool verifyCallback(X509Certificate cert, String host, int port)?})
→ HttpClient
-
获取统一的httpClient
-
initLog({bool enable = false})
→ void
-
-
initMyDefaultDir()
→ Future<void>
-
应用文件根路径
-
initWechatAssetsPicker()
→ void
-
-
isEmail(String str)
→ bool
-
-
isEmptyOrNull(String? str)
→ bool
-
字符串判空
-
isLocalImage(String url)
→ bool
-
非网络图片即为本地图片
-
launchMyUrl(String url, {LaunchMode mode = LaunchMode.externalApplication})
→ Future<bool>
-
Name: url_launcher_utils.dart
-
listDir(String dirPath, {bool recursive = false, bool followLinks = true})
→ Stream<FileSystemEntity>
-
遍历文件夹
-
mailto({required String target, String? cc, String? bcc, String? title, String? body})
→ Future<bool>
-
发送邮件
-
mAppBar({String title = '', bool centerTitle = true, Color titleColor = BaseColors.cFontWhite, double titleFontSize = BaseDimens.dFontSizeTitle, FontWeight titleFontWeight = FontWeight.bold, int titleMaxLine = 1, double height = 0, double? elevation = 0, Color? backgroundColor, Widget? leading, Color? backIconColor = Colors.white, bool backEnable = false, bool autoBackEnable = true, VoidCallback? backPressed, List<Widget>? actions, PreferredSizeWidget? bottom, double? titleSpacing, double? leadingWidth, double? backIconSize = 20, Widget? titleView, SystemUiOverlayStyle? systemOverlayStyle, bool automaticallyImplyLeading = true})
→ PreferredSizeWidget
-
统一appbar
-
mAvatar({required String url, required double size, bool isLocal = false, double borderWidth = 1, Color borderColor = BaseColors.cYellow, BoxShape? shape, String? package})
→ Widget
-
头像框
-
mBorder({Color borderColor = BaseColors.cGrayLine, double width = 0, BorderStyle style = BorderStyle.solid})
→ Border
-
获取共通border
-
mBorderSide({double width = 0.5, Color color = BaseColors.cGrayLine, BorderStyle style = BorderStyle.solid})
→ BorderSide
-
-
mDivider({Color color = BaseColors.cTransparent, double height = 8})
→ Widget
-
获取共通Divider
-
mDividerH({Color color = BaseColors.cTransparent, double height = 20, double width = 1.5, double margin = 0})
→ Widget
-
获取共通Divider
-
mFadeInView({Duration duration = const Duration(milliseconds: 600), Duration delay = Duration.zero, Tween<double>? tween, required Widget child})
→ Widget
-
fadeInView
-
mFormatDate({DateTime? time, List<String>? format, String daySeparator = '-', String middleSeparator = ' ', String timeSeparator = ':'})
→ String
-
日期时间格式化
-
mFormatDateFromStamp({required int stamp, List<String>? format, String daySeparator = '-', String middleSeparator = ' ', String timeSeparator = ':'})
→ String
-
日期时间格式化
-
mImageView(String url, {double? size, double? width, double? height, String placeholderImgPath = GlobalConst.defaultPlaceholderImg, String errorImgPath = GlobalConst.defaultErrorImg, double placeholderSize = 30, double errorSize = 30, BoxFit? fit = BoxFit.cover, Color borderColor = BaseColors.cGrayLine, Color? bgColor, double borderWidth = 0, BoxShape? shape = BoxShape.rectangle, double radius = 0, BorderRadius? borderRadius, bool enableSlideOutPage = false, InitGestureConfigHandler? initGestureConfigHandler, ExtendedImageMode mode = ExtendedImageMode.none, Widget? loadingWidget, double minWidth = 0, double minHeight = 0, double? compressionRatio, String? package, Widget? errorWidget, bool enableFadeIn = true, Duration fadeInDuration = const Duration(milliseconds: 600), Duration timeLimit = const Duration(seconds: 30), Duration timeRetry = const Duration(seconds: 5), int retries = 3, bool cache = true, Clip clipBehavior = Clip.antiAlias})
→ Widget
-
加载网络图片或者本地文件图片
-
mInkView({double? splashRadius, BoxShape splashShape = BoxShape.rectangle, Color? splashColor, Color? bgColor, Border? border, BorderRadius? borderRadius, required Callback onClick, required Widget child})
→ Widget
-
自定义点击波纹的按钮
-
mLine({Color color = BaseColors.cGrayLine, double height = 0.5})
→ Widget
-
分割线
-
mLineH({Color color = BaseColors.cGrayLine, double width = 1})
→ Widget
-
分割线
-
mOverSizeScrollView({required double maxSize, required List<Widget> children, double minSize = 0, Axis scrollDirection = Axis.vertical, double? crossSize = double.infinity, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.start, bool showScrollBar = false, ScrollbarOrientation? scrollbarOrientation})
→ Widget
-
尺寸超过一定值后可滚动
-
mProgressIndicator({bool isIosStyle = true, Color? color, double size = 20, double strokeWidthInAndroid = 4})
→ Widget
-
通用转圈
-
mRoot({required Widget child, WillPopCallback? onWillPop, bool safeArea = true, bool safeTop = false, bool safeBottom = true, bool safeLeft = true, bool safeRight = true, Color? safeAreaBgColor = BaseColors.cWhite})
→ Widget
-
点击空白处关闭键盘
-
mScrollbar({double radius = 2, ScrollbarOrientation? scrollbarOrientation, ScrollController? controller, required Widget child})
→ Widget
-
自定义scrollbar
-
mScrollConfig({ScrollBehavior scrollBehavior = const CupertinoScrollBehavior(), bool scrollBar = false, ScrollbarOrientation? scrollbarOrientation, ScrollController? controller, double radius = 2, required Widget child})
→ Widget
-
自定义scrollConfig,支持添加scrollbar
-
mShowDialog(Widget child, {String? id})
→ MDialog
-
-
mShowTip({String? id, String title = '', String msg = '', bool dismissible = true, List<Widget>? actions, double? maxContentSize, Color titleColor = BaseColors.cFontBlack, double titleFontSize = 16, FontWeight titleFontWeight = FontWeight.bold, int titleMaxLines = 4, Color msgColor = BaseColors.cFontGray, double msgFontSize = 15, FontWeight msgFontWeight = FontWeight.normal, TextAlign msgTextAlign = TextAlign.start, double? minContentSize, Widget? contentWidget, Widget? titleWidget, EdgeInsets msgPadding = EdgeInsets.zero})
→ MDialog
-
-
mSimpleBoxDecoration({Color borderColor = BaseColors.cGrayLine, double borderWidth = 0, BorderStyle borderStyle = BorderStyle.solid, double borderRadius = 4, Color? solidColor, double? elevation, DecorationImage? image})
→ BoxDecoration
-
获取简单BoxDecoration
-
mText({required String msg, double fontSize = 15, FontWeight weight = FontWeight.normal, Color? color, TextAlign textAlign = TextAlign.start, int? maxLines = 1000, TextOverflow overflow = TextOverflow.ellipsis, double? lineHeightFactor = 1.3, FontStyle fontStyle = FontStyle.normal, Color? bgColor, TextStyle? style})
→ Widget
-
获取普通Text
-
mTextField({String? hint, int maxLines = 1, int minLines = 1, IconData? prefixIconData, TextEditingController? controller, int? maxLength, Color iconColor = BaseColors.cPrimaryColor, double fontSize = BaseDimens.dFontSizeNormal, double paddingHorizontal = 6, double paddingVertical = BaseDimens.dPadding, bool obscureText = false, TextInputAction? textInputAction, ValueChanged<String>? onSubmitted, FocusNode? focusNode, BoxBorder? border, double borderWidth = 0.5, TextInputType? keyboardType, List<TextInputFormatter>? formatters, bool isNumOnly = false, BoxDecoration? decoration, TextAlign textAlign = TextAlign.left, OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.editing, bool readOnly = false})
→ Widget
-
获取普通输入框
-
mWillPopScope({required Widget child, WillPopCallback? onWillPop})
→ Widget
-
双击退出
-
notify(String msg, {String title = '', int durationInSec = 2})
→ void
-
-
onBuildFinished(FrameCallback firstFrameCallback, {FrameCallback? everyFrameCallback})
→ void
-
widget build回调
@param firstFrameCallback: 第一帧完成回调
@param everyFrameCallback: 第二及以后帧完成回调
-
pickImage(BuildContext context, {int maxCount = 1, bool enableCamera = true, bool enableRecording = false, List<AssetEntity>? selectedList, bool enablePreview = true})
→ Future<List<AssetEntity>>
-
选择图片
-
post<T>(String path, {Object? data, String contentType = Headers.jsonContentType, ResponseType responseType = ResponseType.json, CancelToken? cancelToken, Options? options, ProgressCallback? onSendProgress, ProgressCallback? onReceiveProgress, Duration? sendTimeout, Duration? receiveTimeout})
→ Future<Response<T>>
-
post请求
-
printLog(String type, dynamic msg, {String tag = "", bool split = false, String? ansiColor})
→ void
-
NSLog日志格式
-
randomNum(int max)
→ int
-
获取随机数[0, max)
-
readFile(String path)
→ Future<ByteData?>
-
-
readFileToBase64Str(String path, {String? defaultStr})
→ Future<String>
-
从文件路径获取文件base64字符串
-
readFileToStr(String path, {String? defaultStr})
→ Future<String>
-
从文件路径获取文件内容
-
readImageFileToUIImage(String imgPath)
→ Future<Image>
-
文件转图片
-
readImageToUnit8List(String imgPath)
→ Future<Uint8List?>
-
-
realLog(String msg, String name)
→ void
-
-
runBaseApp(Widget app, {bool initWeChat = false, String? crashPrefixMsg, RoundAppRun? afterRun})
→ void
-
-
runMyApp(Widget app, {dynamic enableLog = false, Color statusBarColor = BaseColors.cTransparent, Color sysNavigationBarColor = BaseColors.cBlack, bool isStatusBarIconLight = true, bool isSysNavigationBarIconLight = true, List<String>? unPopRoutes, Transition? defaultTransition = Transition.cupertino, RoundAppRun? beforeRun, bool initWeChat = false, String? crashPrefixMsg, RoundAppRun? afterRun})
→ void
-
-
saveDataToFile(String path, ByteData data)
→ Future<File?>
-
保存数据为本地文件
-
saveImage2File(String path, Image? image)
→ Future<File?>
-
-
saveImage2Gallery(Image? image, {bool isTransform2FilePath = true})
→ Future<String>
-
保存图片到相册
-
saveImageData2Gallery(ByteData? data, {bool isTransform2FilePath = true})
→ Future<String>
-
保存图片数据到相册
-
saveImageFile2Gallery(String imgPath, {bool isTransform2FilePath = true})
→ Future<String>
-
保存图片文件到相册
-
saveNetworkImageToPhoto(String url, {bool useCache = true})
→ Future<bool>
-
save network image to photo
-
setGlobalSystemOverlayStyle({Color statusBarColor = BaseColors.cTransparent, bool isStatusBarIconLight = true, Color sysNavigationBarColor = BaseColors.cBlack, bool isSysNavigationBarIconLight = true})
→ void
-
设置全局状态栏、系统导航栏样式(默认深底白字、黑底白字)
-
setSystemOverlayVisible({bool isStatusBarVisible = true, bool isSysNavigationBarVisible = true})
→ void
-
Name: common_ui.dart
-
shareLocalData(Uint8List? data, {String? msg})
→ void
-
-
shareLocalFile(String path, {String? msg})
→ void
-
-
shareStr(String msg)
→ void
-
Name: share_utils.dart
-
showLoading(String msg, {VoidCallback? onClose, double pbSize = 36, Color pbColor = BaseColors.cWhite})
→ CancelFunc
-
显示加载中
@param: msg 消息
@param: onClose 关闭方法回调
@return: 关闭方法
-
tel(String phone)
→ Future<bool>
-
调用拨号页面
-
toast(String msg, {Duration duration = const Duration(seconds: 2), bool onlyOne = false, Color bgColor = BaseColors.cGray, Color textColor = BaseColors.cFontWhite, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 10, vertical: 6), TextStyle? textStyle, ToastLevel level = ToastLevel.normal, AlignmentGeometry align = const Alignment(0, 0.9), bool crossPage = true})
→ void
-
-
vibrate()
→ void
-
-
w({required dynamic msg, String tag = '', bool split = false, String? ansiColor})
→ void
-
打印警告日志
-
writeToFile(String path, String data, {bool append = false})
→ Future<File>
-
写入到文件