base_lib_pub
library
Functions
-
baseApp({Key? key, GlobalKey<NavigatorState>? navigatorKey, GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey, Widget? home, Map<String, WidgetBuilder>? routes, String? initialRoute, RouteFactory? onGenerateRoute, InitialRouteListFactory? onGenerateInitialRoutes, RouteFactory? onUnknownRoute, List<NavigatorObserver> navigatorObservers = const <NavigatorObserver>[], TransitionBuilder? builder, String title = '', GenerateAppTitle? onGenerateTitle, ThemeData? theme, ThemeData? darkTheme, ThemeMode themeMode = ThemeMode.system, CustomTransition? customTransition, Color? color, Map<String, Map<String, String>>? translationsKeys, Translations? translations, TextDirection? textDirection, Locale? locale, Locale? fallbackLocale, Iterable<LocalizationsDelegate>? localizationsDelegates, LocaleListResolutionCallback? localeListResolutionCallback, LocaleResolutionCallback? localeResolutionCallback, Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')], bool showPerformanceOverlay = false, bool checkerboardRasterCacheImages = false, bool checkerboardOffscreenLayers = false, bool showSemanticsDebugger = false, bool debugShowCheckedModeBanner = true, Map<LogicalKeySet, Intent>? shortcuts, ScrollBehavior? scrollBehavior, ThemeData? highContrastTheme, ThemeData? highContrastDarkTheme, Map<Type, Action<Intent>>? actions, bool debugShowMaterialGrid = false, ValueChanged<Routing?>? routingCallback, Transition? defaultTransition, bool? opaqueRoute, VoidCallback? onInit, VoidCallback? onReady, VoidCallback? onDispose, bool? enableLog, LogWriterCallback? logWriterCallback, bool? popGesture, SmartManagement smartManagement = SmartManagement.full, Bindings? initialBinding, Duration? transitionDuration, bool? defaultGlobalState, List<GetPage>? getPages, GetPage? unknownRoute, RouteInformationProvider? routeInformationProvider, RouteInformationParser<Object>? routeInformationParser, RouterDelegate<Object>? routerDelegate, BackButtonDispatcher? backButtonDispatcher, bool useInheritedMediaQuery = false, Color statusBarColor = BaseColors.cTransparent, Color? sysNavigationBarColor, bool isStatusBarIconLight = true, bool isSysNavigationBarIconLight = true, List<String>? unPopRoutes})
→ GetMaterialApp
-
-
baseBeforeRun()
→ Future<void>
-
-
checkPermission({required Permission permission})
→ Future<bool>
-
Name: permission_utils.dart
-
checkStoragePermission()
→ Future<bool>
-
-
clearAllGetxControllers()
→ void
-
清除所有getx控制器
-
clearExtendedImageCache()
→ Future<bool>
-
清除ExtendedImage缓存
-
clickBack({dynamic result, String? route})
→ 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>
-
压缩图片
-
createDio({String baseUrl = '', Duration connectTimeout = const Duration(seconds: 10), Duration? receiveTimeout = const Duration(seconds: 30), bool isAddLogInterceptor = true, bool ignoreCertificate = false, bool isClientGlobal = false, String? certPem, bool verifyCallback(X509Certificate cert, String host, int port)?, HttpClient? httpClient})
→ Dio
-
-
createDir(String path)
→ void
-
创建文件夹
-
createFile(String path)
→ void
-
创建文件
-
createHttpClient({bool ignoreCertificate = false, String? certPem, bool isClientGlobal = false, bool verifyCallback(X509Certificate cert, String host, int port)?})
→ HttpClient
-
获取统一的httpClient
-
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
-
定时循环执行
-
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, Dio? dio})
→ 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图片路径
-
getKeyboardHeight(BuildContext context)
→ double
-
获取键盘高度
-
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
-
隐藏软键盘
-
initCrashHandler({String? prefixMsg, dynamic toastError = false})
→ void
-
Name: crash_utils.dart
-
initGlobalDio({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
-
initMyDefaultDir()
→ Future<void>
-
应用文件根路径
-
initWechatAssetsPicker()
→ void
-
-
isEmail(String str)
→ bool
-
-
isEmptyOrNull(String? str)
→ bool
-
字符串判空
-
isGranted(PermissionStatus status)
→ 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? route, String title = '', bool? centerTitle, Color? titleColor, double? titleFontSize, FontWeight? titleFontWeight, int titleMaxLine = 1, double height = 0, double? elevation, bool backEnable = false, bool autoBackEnable = true, Color? backgroundColor, IconData? backIconData, Color? backIconColor, Widget? leading, VoidCallback? backPressed, List<Widget>? actions, PreferredSizeWidget? bottom, double? titleSpacing, double? leadingWidth, double? backIconSize = 20, Widget? titleView, SystemUiOverlayStyle? systemOverlayStyle, bool automaticallyImplyLeading = true, String? semanticsLabel, double? scrolledUnderElevation, dynamic backResult, EdgeInsetsGeometry? padding})
→ PreferredSizeWidget
-
统一appbar
-
mAvatar({required String url, required double size, bool isLocal = false, double borderWidth = 1, Color? borderColor, Color? bgColor, BoxShape? shape, String? package, String? semanticLabel})
→ 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
-
-
mBoxDecoration({Color borderColor = BaseColors.cGrayLine, double borderWidth = 0, BorderStyle borderStyle = BorderStyle.solid, double borderRadius = 4, Color? solidColor, double? elevation, DecorationImage? image})
→ BoxDecoration
-
获取简单BoxDecoration
-
mButton({required VoidCallback onClick, String? text, double? textFontSize, Color? textColor, FontWeight? textWeight, EdgeInsets? iconPadding, EdgeInsets? textPadding, Color? bgColor, OutlinedBorder? shape, double borderRadius = 8, IconData? iconData, Icon? icon, Color? iconColor, double? iconSize, double? height = 40, double? width, double minWidth = 0, double minHeight = 0, Widget? child, String? semanticsLabel})
→ Widget
-
通用简易按钮
-
mDivider({Color color = BaseColors.cTransparent, double height = 8})
→ Widget
-
获取共通Divider
-
mDividerH({Color color = BaseColors.cTransparent, double height = 0, 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 milliSeparator = '-', bool milliSecond = false})
→ String
-
日期时间格式化
-
mFormatDateFromStamp({required int stamp, List<String>? format, String daySeparator = '-', String middleSeparator = ' ', String timeSeparator = ':', String milliSeparator = '-', bool milliSecond = false})
→ 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, HttpClient? httpClient, String? semanticLabel})
→ 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
-
分割线
-
mLoadingView({String? msg, Color msgColor = Colors.white, double msgFontSize = 14, TextAlign msgAlign = TextAlign.center, TextStyle? msgStyle, int msgMaxLines = 2, TextOverflow msgOverflow = TextOverflow.ellipsis, EdgeInsets msgPadding = const EdgeInsets.fromLTRB(8, 16, 8, 4), double pbSize = defaultLoadingPbSize, Color pbColor = BaseColors.cWhite, double contentCornerRadius = 8, Color contentBgColor = Colors.black54, double? contentWidth, double? contentHeight, EdgeInsets contentPadding = const EdgeInsets.all(12)})
→ 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
-
尺寸超过一定值后可滚动
-
mPopScope({bool? canPop, PopInvokedCallback? onPopInvoked, required Widget child, String? route})
→ Widget
-
-
mProgressIndicator({bool isIosStyle = true, Color? color, double size = 20, double strokeWidthInAndroid = 4})
→ Widget
-
通用转圈
-
mRoot({required Widget child, String? route, bool? canPop, PopInvokedCallback? popInvokedCallback, bool safeArea = true, bool safeTop = false, bool safeBottom = true, bool safeLeft = true, bool safeRight = true, Color? safeAreaBgColor, GestureTapCallback? onScreenTap})
→ 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
-
-
mText(String msg, {double? fontSize, FontWeight? weight, Color? color, TextAlign? textAlign, int? maxLines = 1000, TextOverflow? overflow, double? lineHeightFactor, FontStyle? fontStyle, Color? bgColor, TextStyle? style, String? semanticsLabel, TextDecoration decoration = TextDecoration.none})
→ Widget
-
获取普通Text
-
mTextField({String? hint, int maxLines = 1, int minLines = 1, Widget? prefix, IconData? prefixIconData, double? prefixIconSize, EdgeInsets prefixIconPadding = const EdgeInsets.only(left: 6), TextEditingController? controller, Color? textColor, int? maxLength, Color? iconColor, Color? hintColor, double? fontSize, double fontHeight = 1.2, double paddingHorizontal = 6, double paddingVertical = BaseDimens.dPadding, bool obscureText = false, TextInputAction? textInputAction, ValueChanged<String>? onSubmitted, FocusNode? focusNode, BoxBorder? border, Color borderColor = BaseColors.cGrayLine, double borderWidth = 0.5, TextInputType? keyboardType, List<TextInputFormatter>? formatters, bool isNumOnly = false, BoxDecoration? decoration, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.editing, bool readOnly = false, bool autofocus = false})
→ Widget
-
获取普通输入框
-
notify(String msg, {String title = '', int durationInSec = 2})
→ void
-
-
onBuildFinished(FrameCallback firstFrameCallback, {FrameCallback? everyFrameCallback})
→ void
-
widget build回调
@param firstFrameCallback: 第一帧完成回调
@param everyFrameCallback: 第二及以后帧完成回调
-
parsePermissionTip(Permission permission)
→ String
-
根据权限自动匹配提示文字
-
pickImage(BuildContext context, {int maxCount = 1, bool enableCamera = true, bool enableRecording = false, List<AssetEntity>? selectedList, bool enablePreview = true, String? requestStorageMsg, String? failedStorageMsg, String? requestCameraMsg, String? failedCameraMsg})
→ 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, Dio? dio})
→ Future<Response<T>>
-
post请求
-
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?>
-
-
requestPermission({required Permission permission, String? requestMsg, String? failedMsg})
→ Future<bool>
-
请求权限
-
requestPermissionFailed({required Permission permission, String? failedMsg})
→ void
-
授权失败,开始弹框提示并提供手动授权选择
-
runBaseApp(Widget app, {bool initWeChat = false, String? crashPrefixMsg, RoundAppRun? afterRun})
→ void
-
-
runMyApp(Widget app, {dynamic enableLog = false, RoundAppRun? beforeRun, bool initWeChat = false, String? crashPrefixMsg, RoundAppRun? afterRun, bool clearGetxControllersBeforeExit = true})
→ 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, 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({VoidCallback? onClose, String? msg, Color msgColor = Colors.white, TextAlign msgAlign = TextAlign.center, int msgMaxLines = 2, TextOverflow msgOverflow = TextOverflow.ellipsis, TextStyle? msgStyle, double msgFontSize = 14, double pbSize = defaultLoadingPbSize, Color pbColor = BaseColors.cWhite, double? contentWidth, double? contentHeight, EdgeInsets contentPadding = const EdgeInsets.all(12), EdgeInsets msgPadding = const EdgeInsets.fromLTRB(8, 20, 8, 4), double contentCornerRadius = 8, Color contentBgColor = Colors.black54, LoadingBuilder? builder})
→ CancelFunc
-
显示加载中
@param: msg 消息
@param: onClose 关闭方法回调
@return: 关闭方法
-
stopVibrate()
→ void
-
停止振动
-
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({int duration = 500, int amplitude = -1, Function? onFailedCallback, int repeat = 0, int repeatInterval = 50, List<int>? pattern, List<int>? intensities})
→ void
-
振动
-
writeToFile(String path, String data, {bool append = false})
→ Future<File>
-
写入到文件