Flutter插件lesntecforruixin的使用方法分享
Flutter插件lesntecforruixin的使用方法分享
一. 接入项目:
1. iOS端:
由于package
内有关于配网的功能, 所以需要在appId
中引入以下功能, 确保配网功能完整:
- Xcode -> Signing & Capabilities -> + Capability:
- Access WIFI Information
- Hotspot Configuration
- Wireless Accessory Configuration
并且需要到苹果开发者中心设置相关事项, 并更新证书。
2. Android端:
需要在manifest.xml
中添加以下内容:
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
详情可参照example。
二. 文件目录介绍:
1. flutter:
① component:
组件的封装, 若代码内有问题, 可以沟通, 领慧配合修改。
② models:
数据模型类, scan_model.dart
里的模型贵司会用到, 记录着每一条测站数据的详细情况, 上传文件, 数据库读取, 文件读取都是通过此类完成。
③ constant:
常量参数。
④ utils:
工具类, 若代码内有问题, 可以沟通, 领慧配合修改。
⑤ ruixin:
核心对外API, 内包含的方法为静态方法, 包含(批量上传文件, 获取文件列表, 寻找文件等), 方便贵司调用。
⑥ viewModel:
工具类, 若代码内有问题, 可以沟通, 领慧配合修改。
⑦ room.dart:
项目的核心类, 通过创建:
Widget view = Room(
accessKey: accessKey!,
accessSecret: accessSecret!,
uniqueId: uniqueId!,
suiteId: suiteId!,
measureMode: measureMode!,
phaseCode: phaseCode!,
);
直接进入此页面, 详情可以参考example/main.dart
文件, 具体参数若有疑问可以及时沟通。
⑧ upload_demo:
上传列表关于ruixin/lesntec_utils
目录下文件的调用示例, Room.dart
中, nav
上有个按钮是前往upload_demo
的, 待对接完成后会发布新版本, 删除此按钮与upload_demo
。
2. iOS端:
① UploadPlugin.swift:
上传桥接的工具类, 负责上传文件到OSS。
② WifiPlugin.swift:
配网桥接的工具类。
3. Android端:
① UploadPlugin.kt:
上传桥接的工具类, 负责上传文件到OSS。
② WifiPlugin.kt:
配网桥接的工具类。
三. 对外接口类:
flutter
目录下的ruixin/lesntec_units.dart
:
static loadDownloadList(Function(List<List<String>>?) callback);
示例代码:
1. main.dart
:
import 'package:flutter/material.dart';
import 'package:lesntecforruixin/lesntecforruixin.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
[@override](/user/override)
Widget build(BuildContext context) {
const scheme = ColorScheme(
brightness: Brightness.light,
error: Colors.red,
primary: Colors.white,
onPrimary: berBlue500,
secondary: berSecondary200,
onSecondary: Colors.white,
onError: Colors.red,
background: berBackground,
onBackground: berBackground2,
surface: Colors.grey,
onSurface: Colors.green);
const dartScheme = ColorScheme(
brightness: Brightness.dark,
error: Colors.red,
primary: Colors.white,
onPrimary: Colors.white,
secondary: berSecondary200,
onSecondary: berSecondary700,
onError: Colors.red,
background: berDarkBackground3,
onBackground: berDarkBackground3,
surface: secondBackgroundDark,
onSurface: berwhite);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(colorScheme: scheme),
darkTheme: ThemeData(colorScheme: dartScheme),
home: const Homw(),
);
}
}
class Homw extends StatefulWidget {
const Homw({super.key});
[@override](/user/override)
State<Homw> createState() => _HomwState();
}
class _HomwState extends State<Homw> {
String? accessKey;
String? accessSecret;
String? uniqueId;
String? suiteId;
String? measureMode;
String? phaseCode;
[@override](/user/override)
initState() {
super.initState();
loadData();
}
loadData() async {
String accessKeyTemp = await UnitsDataTool.getValue("accessKey", "");
String accessSecretTemp = await UnitsDataTool.getValue("accessSecret", "");
String uniqueIdTemp = await UnitsDataTool.getValue("uniqueId", "");
String suiteIdTemp = await UnitsDataTool.getValue("suiteId", "");
String measureModeTemp = await UnitsDataTool.getValue("measureMode", "");
String phaseCodeTemp = await UnitsDataTool.getValue("phaseCode", "");
setState(() {
accessKey = accessKeyTemp;
accessSecret = accessSecretTemp;
uniqueId = uniqueIdTemp;
suiteId = suiteIdTemp;
measureMode = measureModeTemp;
phaseCode = phaseCodeTemp;
});
}
[@override](/user/override)
Widget build(BuildContext context) {
TextEditingController controller1 = TextEditingController();
controller1.text = accessKey ?? "";
controller1.addListener(() {});
TextEditingController controller2 = TextEditingController();
controller2.text = accessSecret ?? "";
controller2.addListener(() {});
TextEditingController controller3 = TextEditingController();
controller3.text = uniqueId ?? "";
controller3.addListener(() {});
TextEditingController controller4 = TextEditingController();
controller4.text = suiteId ?? "";
controller4.addListener(() {});
TextEditingController controller5 = TextEditingController();
controller5.text = measureMode ?? "";
controller5.addListener(() {});
TextEditingController controller6 = TextEditingController();
controller6.text = phaseCode ?? "";
controller6.addListener(() {});
return Scaffold(
backgroundColor: UnitsForUI.conversionBackgroundColor(context),
appBar: AppBar(
title: Text(
'测试入口',
maxLines: 2,
style: TextStyle(
fontSize: 14,
color: UnitsForUI.conversionNormalTextColor(context)),
),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('accessKey'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 40,
child: TextField(
cursorColor: Colors.black,
controller: controller1,
onChanged: (str) {
accessKey = str;
},
style: const TextStyle(fontSize: 14),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('accessSecret'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 100,
child: TextField(
cursorColor: Colors.black,
controller: controller2,
onChanged: (str) {
accessSecret = str;
},
maxLines: 2,
style: const TextStyle(fontSize: 14, color: Colors.black),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('measureMode'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 40,
child: TextField(
cursorColor: Colors.black,
controller: controller5,
onChanged: (str) {
measureMode = str;
},
style: const TextStyle(fontSize: 14),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('uniqueId'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 40,
child: TextField(
cursorColor: Colors.black,
controller: controller3,
onChanged: (str) {
uniqueId = str;
},
style: const TextStyle(fontSize: 14),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('suiteId'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 100,
child: TextField(
cursorColor: Colors.black,
controller: controller4,
maxLines: 2,
onChanged: (str) {
suiteId = str;
},
style: const TextStyle(fontSize: 14),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
Container(
margin: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('phaseCode'),
Container(
margin: const EdgeInsets.only(left: 20),
width: 200,
height: 40,
child: TextField(
cursorColor: Colors.black,
controller: controller6,
onChanged: (str) {
phaseCode = str;
},
style: const TextStyle(fontSize: 14),
decoration: const InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 1,
style: BorderStyle.solid)),
),
),
),
],
),
),
ElevatedButton(
style: const ButtonStyle(
padding: MaterialStatePropertyAll(
EdgeInsets.only(left: 50, right: 50)),
backgroundColor: MaterialStatePropertyAll(themeIconColor),
),
child: const Text(
'确认',
style: TextStyle(color: Colors.white),
),
onPressed: () => _sureClick(),
),
],
),
),
);
}
void _sureClick() {
UnitsDataTool.saveString("accessKey", accessKey);
UnitsDataTool.saveString("accessSecret", accessSecret);
UnitsDataTool.saveString("uniqueId", uniqueId);
UnitsDataTool.saveString("suiteId", suiteId);
UnitsDataTool.saveString("measureMode", measureMode);
UnitsDataTool.saveString("phaseCode", phaseCode);
Widget view = Room(
accessKey: accessKey!,
accessSecret: accessSecret!,
uniqueId: uniqueId!,
suiteId: suiteId!,
measureMode: measureMode!,
phaseCode: phaseCode!,
);
MaterialPageRoute route = MaterialPageRoute(builder: (context) => view);
Navigator.push(context, route);
}
}
更多关于Flutter插件lesntecforruixin的使用方法分享的实战教程也可以访问 https://www.itying.com/category-92-b0.html
更多关于Flutter插件lesntecforruixin的使用方法分享的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
在 Flutter 中,lesntecforruixin
这个插件并不是一个广泛使用或官方支持的插件。如果你在某个项目中遇到了这个插件,或者你从某个来源获取了这个插件,以下是一些探索和使用它的步骤:
1. 查找插件来源
- 查看
pubspec.yaml
文件: 如果你的项目中包含了这个插件,首先查看pubspec.yaml
文件,看看是否有关于这个插件的说明或链接。 - 在线搜索: 尝试在搜索引擎或 pub.dev 上搜索
lesntecforruixin
,看看是否有相关的文档或项目。
2. 查看插件文档
- 如果插件有文档或 README 文件,仔细阅读以了解其功能和用法。
- 如果没有文档,尝试查看插件的源代码(通常在
lib
目录下),了解它提供了哪些功能。
3. 导入插件
在 pubspec.yaml
文件中添加插件依赖:
dependencies:
lesntecforruixin: ^版本号
然后运行 flutter pub get
来获取插件。
4. 使用插件
-
导入插件: 在 Dart 文件中导入插件:
import 'package:lesntecforruixin/lesntecforruixin.dart';
-
调用功能: 尝试调用插件提供的函数或类,查看其功能。例如:
Lesntecforruixin.initialize();