app直播源码,收到消息时出现弹窗
app直播源码,收到消息时出现弹窗实现的相关代码
Flutter toast库配置,可参考fluttertoast配置引用
1.在pubspec.yaml中配置fluttertoast库,通过Pub get 获取fluttertoast的版本,通过Pub upgrade更新,eg:
1 | <br> # The following adds the Cupertino Icons font to your application.<br> # Use with the CupertinoIcons class for iOS style icons.<br> cupertino_icons: ^1.0.2<br> provider: ^5.0.0<br> fluttertoast: ^8.0.8 |
2.在需要显示toast的dart文件中,import fluttertoast.dart,eg:
1 | <br>import 'package:fluttertoast/fluttertoast.dart' ; |
3.fluttertoast.dart源码查看
1 | <br> /// Summons the platform's showToast which will display the message<br> ///<br> /// Wraps the platform's native Toast for android.<br> /// Wraps the Plugin https://github.com/scalessec/Toast for iOS<br> /// Wraps the https://github.com/apvarun/toastify-js for Web<br> ///<br> /// Parameter [msg] is required and all remaining are optional<br> static Future<bool?> showToast({<br> required String msg,<br> Toast? toastLength,<br> int timeInSecForIosWeb = 1,<br> double? fontSize,<br> ToastGravity? gravity,<br> Color? backgroundColor,<br> Color? textColor,<br> bool webShowClose = false,<br> webBgColor: "linear-gradient(to right, #00b09b, #96c93d)",<br> webPosition: "right",<br> }) async {<br> String toast = "short";<br> if (toastLength == Toast.LENGTH_LONG) {<br> toast = "long";<br> }<br> <br> String gravityToast = "bottom";<br> if (gravity == ToastGravity.TOP) {<br> gravityToast = "top";<br> } else if (gravity == ToastGravity.CENTER) {<br> gravityToast = "center";<br> } else {<br> gravityToast = "bottom";<br> }<br> <br>//lines from 78 to 97 have been changed in order to solve issue #328<br> if (backgroundColor == null) {<br> backgroundColor = Colors.black;<br> }<br> if (textColor == null) {<br> textColor = Colors.white;<br> }<br> final Map<String, dynamic> params = <String, dynamic>{<br> 'msg': msg,<br> 'length': toast,<br> 'time': timeInSecForIosWeb,<br> 'gravity': gravityToast,<br> 'bgcolor': backgroundColor != null ? backgroundColor.value : null,<br> 'iosBgcolor': backgroundColor != null ? backgroundColor.value : null,<br> 'textcolor': textColor != null ? textColor.value : null,<br> 'iosTextcolor': textColor != null ? textColor.value : null,<br> 'fontSize': fontSize,<br> 'webShowClose': webShowClose,<br> 'webBgColor': webBgColor,<br> 'webPosition': webPosition<br> };<br> <br> bool? res = await _channel.invokeMethod('showToast', params);<br> return res;<br> }<br>} |
以上就是 app直播源码,收到消息时出现弹窗实现的相关代码,更多内容欢迎关注之后的文章
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现