|
@@ -31,7 +31,7 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
String name = '物流';
|
|
String name = '物流';
|
|
|
BluetoothUtils bluetooth = BluetoothUtils();
|
|
BluetoothUtils bluetooth = BluetoothUtils();
|
|
|
List < BtInfoObj > btList = [];
|
|
List < BtInfoObj > btList = [];
|
|
|
- Set < BtInfoObj > btSet = Set();
|
|
|
|
|
|
|
+ Set btSet = Set();
|
|
|
List printTypeList = ["全部", "配件商", "修理厂", "司机", "货物", "货物外", "不打印"];
|
|
List printTypeList = ["全部", "配件商", "修理厂", "司机", "货物", "货物外", "不打印"];
|
|
|
static
|
|
static
|
|
|
var printTypeMap = {
|
|
var printTypeMap = {
|
|
@@ -100,25 +100,52 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- // getKey('btList').then((value){
|
|
|
|
|
- // //print(value);
|
|
|
|
|
- // if(value!=null && check==true){
|
|
|
|
|
- // List<BtInfoObj> tempList =json.decode(value);
|
|
|
|
|
- // setState(() {
|
|
|
|
|
- // btList=tempList;
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ getKey('btList').then((value) {
|
|
|
|
|
+ print(value);
|
|
|
|
|
+ if (value != '' && check == true) {
|
|
|
|
|
+ List tempList = [];
|
|
|
|
|
+ for (int i = 0; i < 999; i++) {
|
|
|
|
|
+ if (value.indexOf('&') != -1) {
|
|
|
|
|
+ int index = value.indexOf('&');
|
|
|
|
|
+ tempList.add(value.substring(0, index));
|
|
|
|
|
+ value = value.substring(index + 1, value.length);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < tempList.length; i++) {
|
|
|
|
|
+ BtInfoObj tempObj = BtInfoObj(name: tempList[i], showLoadStauts: false, connectStatus: false);
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ btList.add(tempObj);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
onEvent(Object obj) {
|
|
onEvent(Object obj) {
|
|
|
|
|
+ print('进入onEvent回调${obj}');
|
|
|
if (obj.toString().indexOf('||') != -1) { //过滤开始搜索和结束搜索
|
|
if (obj.toString().indexOf('||') != -1) { //过滤开始搜索和结束搜索
|
|
|
- BtInfoObj tempObj = BtInfoObj(name: obj.toString(), showLoadStauts: false, connectStatus: false);
|
|
|
|
|
- btSet.add(tempObj);
|
|
|
|
|
|
|
+ btSet.add(obj.toString()); //去重
|
|
|
|
|
+ List tempBtList = btSet.toList();
|
|
|
|
|
+ List<BtInfoObj> tempBtList2 = [];
|
|
|
|
|
+ for (int i = 0; i < tempBtList.length; i++) {
|
|
|
|
|
+ tempBtList2.add(
|
|
|
|
|
+ BtInfoObj(name: tempBtList[i], showLoadStauts: false, connectStatus: false)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
setState(() {
|
|
setState(() {
|
|
|
- btList = btSet.toList();
|
|
|
|
|
|
|
+ btList =tempBtList2;
|
|
|
});
|
|
});
|
|
|
- //setKey('btList', btList.toString());
|
|
|
|
|
|
|
+ print('设置btList完成');
|
|
|
|
|
+ String tempStr = '';
|
|
|
|
|
+ for (int i = 0; i < btList.length; i++) {
|
|
|
|
|
+ tempStr += '${btList[i].name}&';
|
|
|
|
|
+ }
|
|
|
|
|
+ print('设置临时字符串');
|
|
|
|
|
+ print(tempStr);
|
|
|
|
|
+ setKey('btList', tempStr);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -489,21 +516,21 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
return Container(
|
|
return Container(
|
|
|
height: ScreenUtil.getInstance().setHeight(350),
|
|
height: ScreenUtil.getInstance().setHeight(350),
|
|
|
padding: EdgeInsets.all(ScreenUtil.getInstance().setHeight(30)),
|
|
padding: EdgeInsets.all(ScreenUtil.getInstance().setHeight(30)),
|
|
|
- child: (btList.length > 0 && check==true) ? ListView.builder(
|
|
|
|
|
|
|
+ child: (btList.length > 0 && check == true) ? ListView.builder(
|
|
|
itemCount: btList.length,
|
|
itemCount: btList.length,
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
return _btItem(btList[index], index);
|
|
return _btItem(btList[index], index);
|
|
|
},
|
|
},
|
|
|
- ) : check==true?_searchBt():Center()
|
|
|
|
|
|
|
+ ) : check == true ? _searchBt() : Center()
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Widget _btItem(BtInfoObj obj, int index) {
|
|
Widget _btItem(BtInfoObj obj, int index) {
|
|
|
- print(obj.name);
|
|
|
|
|
|
|
+ // print(obj.name);
|
|
|
int tempIndex = obj.name.indexOf('||');
|
|
int tempIndex = obj.name.indexOf('||');
|
|
|
String name = obj.name.substring(0, tempIndex);
|
|
String name = obj.name.substring(0, tempIndex);
|
|
|
String btAddress = obj.name.substring(tempIndex + 2, obj.name.length);
|
|
String btAddress = obj.name.substring(tempIndex + 2, obj.name.length);
|
|
|
- print(btAddress);
|
|
|
|
|
|
|
+ // print(btAddress);
|
|
|
return InkWell(
|
|
return InkWell(
|
|
|
child: Padding(
|
|
child: Padding(
|
|
|
padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|
|
padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|