4 Star 0 Fork 0

龙呤枫/YCSDKResource

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
query_device_info.dart 4.84 KB
一键复制 编辑 原始数据 按行查看 历史
kuangdeyin 提交于 1个月前 . 增加flutter sdk demo
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:yc_product_plugin/yc_product_plugin.dart';
class QueryDeviceInfoWidget extends StatefulWidget {
const QueryDeviceInfoWidget({super.key});
@override
State<QueryDeviceInfoWidget> createState() => _QueryDeviceInfoWidgetState();
}
//查询设备信息
class _QueryDeviceInfoWidgetState extends State<QueryDeviceInfoWidget> {
String _displayedText = "Result";
final _items = [
"Basic info",
"Mac Address",
"Device model",
"Mcu",
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Query"),
),
body: Column(
children: [
Expanded(
flex: 1,
child: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Text(
_displayedText,
textAlign: TextAlign.left,
style: const TextStyle(
fontSize: 16.0,
),
),
),
),
Expanded(
flex: 2,
child: ListView.separated(
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
EasyLoading.show(status: "");
setState(() {
_displayedText = "";
});
switch (index) {
case 0:
//查询设备基础信息
YcProductPlugin().queryDeviceBasicInfo().then((value) {
if (value?.statusCode == PluginState.succeed) {
//查询成功
EasyLoading.showSuccess("");
final info = value?.data ;
setState(() {
_displayedText = info.toString();
});
} else {
EasyLoading.showError("Not support");
}
},);
case 1:
//查询设备mac地址
YcProductPlugin()
.queryDeviceMacAddress()
.then((value) {
if (value?.statusCode == PluginState.succeed) {
//查询成功
EasyLoading.showSuccess("");
final macAddress = value?.data ?? "";
setState(() {
_displayedText = macAddress;
});
} else {
EasyLoading.showError("Not support");
}
});
case 2:
//查询设备型号
YcProductPlugin().queryDeviceModel().then((value) {
if (value?.statusCode == PluginState.succeed) {
//查询成功
final model = value?.data ?? "";
EasyLoading.showSuccess("");
setState(() {
_displayedText = model;
});
} else {
EasyLoading.showError("Not support");
}
});
case 3:
//查询设备mcu
YcProductPlugin().queryDeviceMCU().then((value) {
if (value?.statusCode == PluginState.succeed) {
//查询成功
EasyLoading.showSuccess("");
final mcu =
value?.data ?? DeviceMcuPlatform.nrf52832;
setState(() {
_displayedText = mcu.toString();
});
} else {
EasyLoading.showError("Not support");
}
});
default:
break;
}
},
child: ListTile(
title: Text("${index + 1}. ${_items[index]}"),
),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider();
},
itemCount: _items.length),
),
],
),
);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/easylive/ycsdkresource.git
git@gitee.com:easylive/ycsdkresource.git
easylive
ycsdkresource
YCSDKResource
master

搜索帮助