Commit e973968cec08d4a6828fff10767c6f6a880a91f7

Authored by wdn127929
1 parent 9e9f3f3c

null处理

... ... @@ -38,6 +38,7 @@ class _ContantLeftPageState extends State<ContantLeftPage> {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await contantShowModel.getUserHistorys(context, params);
await contantShowModel.searchData(contantShowModel.controller.text);
}
@override
... ...
... ... @@ -63,76 +63,98 @@ class _ContactListPageState extends State<ContactListPage>
vertical: ScreenUtil().setWidth(10)),
height: ScreenUtil().setWidth(45 * 2),
// alignment: Alignment.center,
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20 * 2),
vertical: ScreenUtil().setWidth(14)),
decoration: BoxDecoration(
color: MyColours.color_F0F0F0,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(24 * 2))),
child: TextField(
controller: contantShowModel.controller,
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30),
textBaseline: TextBaseline.alphabetic),
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "搜索联系人",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
),
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: InputBorder.none,
//左边图标设置
icon: Image.asset(
Utils.getImgPath('search'),
width: ScreenUtil().setWidth(30),
child: Stack(
children: [
Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20 * 2),
vertical: ScreenUtil().setWidth(14)),
decoration: BoxDecoration(
color: MyColours.color_F0F0F0,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(24 * 2))),
child: TextField(
maxLines: 1,
controller: contantShowModel.controller,
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30)),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
right: ScreenUtil().setWidth(70 * 2)),
hintText: "搜索联系人",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(30),
),
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: InputBorder.none,
// 左边图标设置
icon: Image.asset(
Utils.getImgPath('search'),
width: ScreenUtil().setWidth(30),
),
//右边图标设置
// suffixIcon:
),
//右边图标设置
suffixIcon: contantShowModel
.controller.text ==
''
? Container()
: GestureDetector(
child: Container(
height: ScreenUtil().setWidth(30),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.done,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
contantShowModel.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
Positioned(
right: 0,
top: 0,
bottom: 0,
child: Offstage(
offstage:
contantShowModel.controller.text ==
'',
child: GestureDetector(
child: Container(
padding: EdgeInsets.only(
right: ScreenUtil()
.setWidth(20 * 2)),
// color: Colors.orange,
height:
ScreenUtil().setWidth(45 * 2),
width:
ScreenUtil().setWidth(100 * 2),
alignment: Alignment.centerRight,
child: Image.asset(
Utils.getImgPath('clear'),
width: ScreenUtil().setWidth(30),
alignment: Alignment.centerRight,
child: Image.asset(
Utils.getImgPath('clear'),
width:
ScreenUtil().setWidth(30),
),
height: ScreenUtil().setWidth(30),
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback(((_) {
contantShowModel.controller
.clear();
contantShowModel.searchData('');
}));
},
)),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
onChanged: (value) {
setState(() {});
// _searchSellerLocation();
contantShowModel.searchData(value);
},
onEditingComplete: () {
// _searchSellerLocation();
// _focusNode.unfocus();
},
),
),
onTap: () {
WidgetsBinding.instance
.addPostFrameCallback(((_) {
contantShowModel.controller
.clear();
contantShowModel.searchData('');
}));
},
)))
],
)),
Container(
padding: EdgeInsets.only(
... ...
... ... @@ -119,6 +119,7 @@ class _ContantRightPageState extends State<ContantRightPage> {
contantShowModel.pageStateRight = PageState.Empty;
}
});
await contantShowModel.searchData(contantShowModel.controller.text);
}
@override
... ...
... ... @@ -89,10 +89,10 @@ class ContantShowModel extends ChangeNotifier {
// String pinyin = userHistorys[i].pinyin;
String phone = userHistorys[i].phone;
List<String> pinyinList = userHistorys[i].pinyinList;
if (name.contains(key) ||
pinyinFirst.contains(key) ||
phone.contains(key) ||
pinyinList.contains(key)) {
if ((name != null && name.contains(key)) ||
(pinyinFirst != null && pinyinFirst.contains(key)) ||
(phone != null && phone.contains(key)) ||
(pinyinList != null && pinyinList.contains(key))) {
userHistorysShow.add(userHistorys[i]);
}
}
... ... @@ -102,10 +102,10 @@ class ContantShowModel extends ChangeNotifier {
List<String> pinyinList = contacts[i].pinyinList;
// String pinyin = contacts[i].pinyin;
String phone = contacts[i].phone;
if (name.contains(key) ||
pinyinFirst.contains(key) ||
phone.contains(key) ||
pinyinList.contains(key)) {
if ((name != null && name.contains(key)) ||
(pinyinFirst != null && pinyinFirst.contains(key)) ||
(phone != null && phone.contains(key)) ||
(pinyinList != null && pinyinList.contains(key))) {
contactsShow.add(contacts[i]);
}
}
... ...
... ... @@ -54,7 +54,7 @@ class NoteBookModel extends ChangeNotifier {
return Notebook.fromJson(value);
}).toList();
if (notebooks.isEmpty) {
pageState = PageState.Success;
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
}
... ...