输入框遮罩问题
输入框被键盘遮罩 需要将输入框所在页面移动到键盘上部分
需要两步
第一步然所在页面能够移动 即所在页面外部包裹 一个可移动界面 比如 SingleChildScrollView
第二部 将输入框放在键盘上边 给所在界面加个padding
例如
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom), // !important
color: Colors.transparent,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("工种",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: getWorkTypeItems(),
onChanged: (value) {
state(() {
chooseId = value;
records.forEach((data) {
if (data.id == value) {
hintvalue = data.name;
}
});
});
},
hint: new Text(
hintvalue == null ? "请选择" : hintvalue),
),
);
}),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("到岗日期"),
Expanded(
child: Text(""),
),
Container(
child: InkWell(
onTap: () {
getTime();
},
// child: Text(time == null ? "请选择" : '${formatDate(time, [yyyy, "-", mm, "-", dd])}'),
child: Text(
doorTime,
textAlign: TextAlign.center,
),
),
),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("最低预算",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: [
DropdownMenuItem(
child: new Text('2000'),
value: 2000,
),
DropdownMenuItem(
child: new Text('3000'),
value: 3000,
),
DropdownMenuItem(
child: new Text('4000'),
value: 4000,
),
DropdownMenuItem(
child: new Text('5000'),
value: 5000,
),
DropdownMenuItem(
child: new Text('6000'),
value: 6000,
),
DropdownMenuItem(
child: new Text('7000'),
value: 7000,
),
DropdownMenuItem(
child: new Text('8000'),
value: 8000,
),
DropdownMenuItem(
child: new Text('9000'),
value: 9000,
),
DropdownMenuItem(
child: new Text('10000'),
value: 10000,
),
DropdownMenuItem(
child: new Text('11000'),
value: 11000,
),
DropdownMenuItem(
child: new Text('12000'),
value: 12000,
),
DropdownMenuItem(
child: new Text('13000'),
value: 13000,
),
DropdownMenuItem(
child: new Text('14000'),
value: 14000,
),
],
onChanged: (value) {
state(() {
budgetMin = value;
});
},
hint: new Text(budgetMin == null
? "请选择"
: budgetMin.toString() + "元/月"),
),
);
}),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("最高预算",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: [
DropdownMenuItem(
child: new Text('2000'),
value: 2000,
),
DropdownMenuItem(
child: new Text('3000'),
value: 3000,
),
DropdownMenuItem(
child: new Text('4000'),
value: 4000,
),
DropdownMenuItem(
child: new Text('5000'),
value: 5000,
),
DropdownMenuItem(
child: new Text('6000'),
value: 6000,
),
DropdownMenuItem(
child: new Text('7000'),
value: 7000,
),
DropdownMenuItem(
child: new Text('8000'),
value: 8000,
),
DropdownMenuItem(
child: new Text('9000'),
value: 9000,
),
DropdownMenuItem(
child: new Text('10000'),
value: 10000,
),
DropdownMenuItem(
child: new Text('11000'),
value: 11000,
),
DropdownMenuItem(
child: new Text('12000'),
value: 12000,
),
DropdownMenuItem(
child: new Text('13000'),
value: 13000,
),
DropdownMenuItem(
child: new Text('14000'),
value: 14000,
),
DropdownMenuItem(
child: new Text('15000'),
value: 15000,
),
DropdownMenuItem(
child: new Text('16000'),
value: 16000,
),
DropdownMenuItem(
child: new Text('17000'),
value: 17000,
),
DropdownMenuItem(
child: new Text('18000'),
value: 18000,
),
DropdownMenuItem(
child: new Text('19000'),
value: 19000,
),
DropdownMenuItem(
child: new Text('20000'),
value: 20000,
),
DropdownMenuItem(
child: new Text('21000'),
value: 21000,
),
DropdownMenuItem(
child: new Text('22000'),
value: 22000,
),
DropdownMenuItem(
child: new Text('23000'),
value: 23000,
),
DropdownMenuItem(
child: new Text('24000'),
value: 24000,
),
DropdownMenuItem(
child: new Text('25000'),
value: 25000,
),
DropdownMenuItem(
child: new Text('26000'),
value: 26000,
),
DropdownMenuItem(
child: new Text('27000'),
value: 27000,
),
DropdownMenuItem(
child: new Text('28000'),
value: 28000,
),
DropdownMenuItem(
child: new Text('29000'),
value: 29000,
),
DropdownMenuItem(
child: new Text('30000'),
value: 30000,
),
DropdownMenuItem(
child: new Text('不限'),
value: 31000,
),
],
onChanged: (value) {
state(() {
budgetMax = value;
});
},
hint: new Text(budgetMax == null
? "不限"
: (budgetMax == 31000
? "不限"
: budgetMax.toString() + "元/月")),
),
);
}),
],
),
),
Container(
margin: EdgeInsets.only(left: 20, right: 20, top: 10),
child: TextField(
onChanged: (value) {
remark = value;
},
maxLines: 5,
decoration: InputDecoration(
hintText: remark==null? "此处填写服务内容和岗位要求":remark, border: OutlineInputBorder()),
),
),
Container(
padding: EdgeInsets.only(left: 60, right: 60, top: 20),
decoration: BoxDecoration(color: Colors.white),
//color: Colors.white,
child: Row(
children: <Widget>[
Expanded(
child: new MaterialButton(
color: Colors.red,
textColor: Colors.white,
child: new Text('取消'),
onPressed: () {
Navigator.pop(context);
},
),
),
Expanded(
child: new MaterialButton(
color: Colors.red,
textColor: Colors.white,
child: new Text('更新'),
onPressed: () {
updateOrder(model);
},
),
)
],
),
),
],
),
),
);
});
});
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom), // !important
color: Colors.transparent,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("工种",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: getWorkTypeItems(),
onChanged: (value) {
state(() {
chooseId = value;
records.forEach((data) {
if (data.id == value) {
hintvalue = data.name;
}
});
});
},
hint: new Text(
hintvalue == null ? "请选择" : hintvalue),
),
);
}),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("到岗日期"),
Expanded(
child: Text(""),
),
Container(
child: InkWell(
onTap: () {
getTime();
},
// child: Text(time == null ? "请选择" : '${formatDate(time, [yyyy, "-", mm, "-", dd])}'),
child: Text(
doorTime,
textAlign: TextAlign.center,
),
),
),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("最低预算",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: [
DropdownMenuItem(
child: new Text('2000'),
value: 2000,
),
DropdownMenuItem(
child: new Text('3000'),
value: 3000,
),
DropdownMenuItem(
child: new Text('4000'),
value: 4000,
),
DropdownMenuItem(
child: new Text('5000'),
value: 5000,
),
DropdownMenuItem(
child: new Text('6000'),
value: 6000,
),
DropdownMenuItem(
child: new Text('7000'),
value: 7000,
),
DropdownMenuItem(
child: new Text('8000'),
value: 8000,
),
DropdownMenuItem(
child: new Text('9000'),
value: 9000,
),
DropdownMenuItem(
child: new Text('10000'),
value: 10000,
),
DropdownMenuItem(
child: new Text('11000'),
value: 11000,
),
DropdownMenuItem(
child: new Text('12000'),
value: 12000,
),
DropdownMenuItem(
child: new Text('13000'),
value: 13000,
),
DropdownMenuItem(
child: new Text('14000'),
value: 14000,
),
],
onChanged: (value) {
state(() {
budgetMin = value;
});
},
hint: new Text(budgetMin == null
? "请选择"
: budgetMin.toString() + "元/月"),
),
);
}),
],
),
),
Container(
height: 40,
color: Colors.white,
padding: EdgeInsets.only(left: 15, right: 15),
child: Row(
children: <Widget>[
Text("最高预算",
style:
TextStyle(color: Colors.black, fontSize: 16)),
Expanded(
child: Text(""),
),
StatefulBuilder(builder: (context, state) {
return DropdownButtonHideUnderline(
child: DropdownButton(
items: [
DropdownMenuItem(
child: new Text('2000'),
value: 2000,
),
DropdownMenuItem(
child: new Text('3000'),
value: 3000,
),
DropdownMenuItem(
child: new Text('4000'),
value: 4000,
),
DropdownMenuItem(
child: new Text('5000'),
value: 5000,
),
DropdownMenuItem(
child: new Text('6000'),
value: 6000,
),
DropdownMenuItem(
child: new Text('7000'),
value: 7000,
),
DropdownMenuItem(
child: new Text('8000'),
value: 8000,
),
DropdownMenuItem(
child: new Text('9000'),
value: 9000,
),
DropdownMenuItem(
child: new Text('10000'),
value: 10000,
),
DropdownMenuItem(
child: new Text('11000'),
value: 11000,
),
DropdownMenuItem(
child: new Text('12000'),
value: 12000,
),
DropdownMenuItem(
child: new Text('13000'),
value: 13000,
),
DropdownMenuItem(
child: new Text('14000'),
value: 14000,
),
DropdownMenuItem(
child: new Text('15000'),
value: 15000,
),
DropdownMenuItem(
child: new Text('16000'),
value: 16000,
),
DropdownMenuItem(
child: new Text('17000'),
value: 17000,
),
DropdownMenuItem(
child: new Text('18000'),
value: 18000,
),
DropdownMenuItem(
child: new Text('19000'),
value: 19000,
),
DropdownMenuItem(
child: new Text('20000'),
value: 20000,
),
DropdownMenuItem(
child: new Text('21000'),
value: 21000,
),
DropdownMenuItem(
child: new Text('22000'),
value: 22000,
),
DropdownMenuItem(
child: new Text('23000'),
value: 23000,
),
DropdownMenuItem(
child: new Text('24000'),
value: 24000,
),
DropdownMenuItem(
child: new Text('25000'),
value: 25000,
),
DropdownMenuItem(
child: new Text('26000'),
value: 26000,
),
DropdownMenuItem(
child: new Text('27000'),
value: 27000,
),
DropdownMenuItem(
child: new Text('28000'),
value: 28000,
),
DropdownMenuItem(
child: new Text('29000'),
value: 29000,
),
DropdownMenuItem(
child: new Text('30000'),
value: 30000,
),
DropdownMenuItem(
child: new Text('不限'),
value: 31000,
),
],
onChanged: (value) {
state(() {
budgetMax = value;
});
},
hint: new Text(budgetMax == null
? "不限"
: (budgetMax == 31000
? "不限"
: budgetMax.toString() + "元/月")),
),
);
}),
],
),
),
Container(
margin: EdgeInsets.only(left: 20, right: 20, top: 10),
child: TextField(
onChanged: (value) {
remark = value;
},
maxLines: 5,
decoration: InputDecoration(
hintText: remark==null? "此处填写服务内容和岗位要求":remark, border: OutlineInputBorder()),
),
),
Container(
padding: EdgeInsets.only(left: 60, right: 60, top: 20),
decoration: BoxDecoration(color: Colors.white),
//color: Colors.white,
child: Row(
children: <Widget>[
Expanded(
child: new MaterialButton(
color: Colors.red,
textColor: Colors.white,
child: new Text('取消'),
onPressed: () {
Navigator.pop(context);
},
),
),
Expanded(
child: new MaterialButton(
color: Colors.red,
textColor: Colors.white,
child: new Text('更新'),
onPressed: () {
updateOrder(model);
},
),
)
],
),
),
],
),
),
);
});
});