技术博客

归档

2025 年 06 月

自行实现(笨办法) class LoginData{ final int code; final String msg; final List<DataItem> data; LoginData({required this.code, required this.msg, req

2025-06-10

Context是操作资源和系统服务的基础,LocalContext可以在任意compose层级访问,compose框架会自动将Context绑定在当前的Activity或Fragment上。 与系统服务交互 Toast提示信息 val context = LocalContext.curre
tabbar页面之间切换时会卸载(清理所有状态),解决这个问题。 变量、页面滚动状态等都可以保存 class _Page1State extends State<Page1> with AutomaticKeepAliveClientMixin { @override bool get w
RouteObserver+混合RouteAware,监听从其它页面pop回到当前、当前页面通过pop关闭、push到其它页面、push打开到当前页面。 目前仅用到了didPopNext,当从其它页面返回时重新加载部分数据(刷新数据) 仅在StatefulWidget(有状态组件)中可以混入Rout

2025-06-09

本地存储 依赖:https://pub.dev/packages/shared_preferences 安装 flutter pub add shared_preferences 获取实例 var i = await SharedPreferences.getInstance()

2025-06-09

识别一维/二维码目前用了多个模块中最好用的,在安卓中内部使用的是MLKit的barcode scanning捆绑版本,APP体积增加约3~10M。 google官方提供了barcode scanner但是没有捆绑版本(必须有谷歌套件)。 MLKit官方网址:https://developers.go

2025-06-08

修改应用图标 flutter pub add flutter_launcher_icons dart run flutter_launcher_icons:generate #在项目根目录中运行,生成默认配置模版flutter_launcher_icons.yaml #修改其中的image_pa

2025-06-08

请求API、上传文件等 链接:https://pub.dev/packages/http 引入依赖 pubspec.yaml dependencies: http: ^1.4.0 http_parser: ^4.1.2 get请求 var response = await http.

2025-06-06

flutter开发必学的编程语言 变量&常量 var和变量类型不能同时存在 var name = "alice"; // 变量,自动推断为String类型 final int age = 18; //不可变变量 const double PI = 3.1415926; // 编绎时常量 late S

2025-06-02

0).如果使用CNG 如果用了blank模版(项目中没有android目录)则先在项目根目录中执行命令: npx expo prebuild 1).生成上传密钥 expo项目根目录中执行命令: #macOS sudo keytool -genkey -v -keystore my-upload-ke
上一页 下一页