一 GetUtils
GetUtils
是getx
为我们提供一些常用的工具类库,包括值是否为空、是否是数字、是否是视频、图片、音频、PPT、Word、APK、邮箱、手机号码、日期、MD5、SHA1等等。
二 Snackbar
// title String 弹出的标题文字
// message String 弹出的消息文字
// colorText Color title和message的文字颜色
// duration Duration Snackbar弹出的持续时间(默认3秒)
// instantInit bool 当false可以把snackbar 放在initState,默认true
// snackPosition SnackPosition 弹出时的位置,有两个选项【TOP,BOTTOM】默认TOP
// titleText Widget 弹出标题的组件,设置该属性会导致title属性失效
// messageText Widget 弹出消息的组件,设置该属性会导致messageText属性失效
// icon Widget 弹出时图标,显示在title和message的左侧
// shouldIconPulse bool 弹出时图标是否闪烁,默认false
// maxWidth double Snackbar最大的宽度
// margin EdgeInsets Snackbar外边距,默认zero
// padding EdgeInsets Snackbar内边距,默认EdgeInsets.all(16)
// borderRadius double 边框圆角大小,默认15
// borderColor Color 边框的颜色,必须设置borderWidth,否则无效果
// borderWidth double 边框的线条宽度
// backgroundColor Color Snackbar背景颜色,默认Colors.grey.withOpacity(0.2)
// leftBarIndicatorColor Color 左侧指示器的颜色
// boxShadows List Snackbar阴影颜色
// backgroundGradient Gradient 背景的线性颜色
// mainButton TextButton 主要按钮,一般显示发送、确认按钮
// onTap OnTap 点击Snackbar事件回调
// isDismissible bool 是否开启Snackbar手势关闭,可配合dismissDirection使用
// showProgressIndicator bool 是否显示进度条指示器,默认false
// dismissDirection SnackDismissDirection Snackbar关闭的方向
// progressIndicatorController AnimationController 进度条指示器的动画控制器
// progressIndicatorBackgroundColor Color 进度条指示器的背景颜色
// progressIndicatorValueColor Animation 进度条指示器的背景颜色,Animation
// snackStyle SnackStyle Snackbar是否会附加到屏幕边缘
// forwardAnimationCurve Curve Snackbar弹出的动画,默认Curves.easeOutCirc
// reverseAnimationCurve Curve Snackbar消失的动画,默认Curves.easeOutCirc
// animationDuration Duration Snackbar弹出和小时的动画时长,默认1秒
// barBlur double Snackbar背景的模糊度
// overlayBlur double 弹出时的毛玻璃效果值,默认0
// snackbarStatus SnackbarStatusCallback Snackbar弹出或消失时的事件回调(即将打开、已打开、即将关闭、已关闭)
// overlayColor Color 弹出时的毛玻璃的背景颜色
// userInputForm Form 用户输入表单
三 Dialog
// title String 弹出的标题,默认(Alert)
// titlePadding EdgeInsetsGeometry 标题的内边距,默认(EdgeInsets.all(8))
// titleStyle TextStyle 标题的样式
// middleText String 中间内容区域显示的文字
// middleTextStyle TextStyle 中间内容区域显示的文字样式
// content Widget 弹出的内容,该值设置后middleText将无效
// contentPadding EdgeInsetsGeometry 内容的内边距,默认(EdgeInsets.all(8))
// onConfirm VoidCallback 确认按钮回调
// onCancel VoidCallback 取消按钮回调
// onCustom VoidCallback 自定义按钮回调
// cancelTextColor Color 取消按钮文字的颜色
// confirmTextColor Color 确认按钮文字的颜色
// textConfirm String 确认按钮的文字
// textCancel String 取消按钮的文字
// textCustom String 自定义按钮的文字
// confirm Widget 确认按钮的组件
// cancel Widget 取消按钮的组件
// custom Widget 自定义按钮的组件
// backgroundColor Color 弹出框的背景颜色
// barrierDismissible bool 是否可以通过点击背景关闭弹窗
// buttonColor Color 按钮的文字颜色,根据按钮类型来设定不同的位置
// radius double 弹出框的圆角大小,默认20
// actions List 增加额外的子组件
// onWillPop WillPopCallback 拦截关闭之前做一些操作
// navigatorKey GlobalKey 用于打开对话框的key
四 BottomSheet
// bottomsheet Widget 弹出的Widget组件
// backgroundColor Color bottomsheet的背景颜色
// elevation double bottomsheet的阴影
// persistent bool 是否添加到路由中
// shape ShapeBorder 边框形状,一般用于圆角效果
// clipBehavior Clip 裁剪的方式
// barrierColor Color 弹出层的背景颜色
// ignoreSafeArea bool 是否忽略安全适配
// isScrollControlled bool 是否支持全屏弹出,默认false
// useRootNavigator bool 是否使用根导航
// isDismissible bool 点击背景是否可关闭,默认ture
// enableDrag bool 是否可以拖动关闭,默认true
// settings RouteSettings 路由设置
// enterBottomSheetDuration Duration bottomsheet进入时的动画时间
// exitBottomSheetDuration Duration bottomsheet退出时的动画时间
大佬用过getx没?get.BottomSheet和Scaffold中的bottomSheet有什么区别?为啥通过get.BottomSheet不会影响FloatingActionButton的位置,而通过Scaffold设置bottomSheet会影响FloatingActionButton的位置,如果我希望get.BottomSheet和Scaffold 中的 bottomSheet 一样会影响FloatingActionButton 的位置,该怎么做?
根据我的经验:一 get.BottomSheet代表从底部弹出面板,这个面板是覆盖在页面 Scaffold 上的新层,所以无法影响到 Scaffold -> FloatingActionButton 的位置。 二. Scaffold -> BottomSheet 代表在 Scaffold 底部添加一个组件,与get里虽然同名但是两个概念。你是不是想做 一个按钮随着get.BottomSheet的弹出自动升高或降低?可以在get.BottomSheet 顶部写一个相同的按钮。