List<Widget> pages = [
Body(),
GitHubLanguagePage(),
];
int currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: pages[currentIndex],
floatingActionButton: FloatingActionButton(
onPressed: () {
print("add press ");
},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.view_module),
onPressed: () {
setState(() {
currentIndex = 0;
});
print("全部:$currentIndex");
},
),
IconButton(
icon: Icon(Icons.favorite),
onPressed: () {
setState(() {
currentIndex = 1;
});
print("收藏:$currentIndex");
},
),
],
),
),
);
}
Body Widget code:
@override
Widget build(BuildContext context) {
_search('');
print('build ...');
return Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea(
child: Column(
children: [
Container(
margin: EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(
color: Color.fromARGB(255, 225, 226, 230), width: 0.33),
color: Color.fromARGB(255, 239, 240, 244),
borderRadius: BorderRadius.circular(12)),
child: TextField(
autofocus: false,
onChanged: (value) {
_search(value);
},
controller: textEditingController,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
color: Colors.grey,
),
suffixIcon: Offstage(
offstage: textEditingController.text.isEmpty,
child: InkWell(
onTap: () {
textEditingController.clear();
_search('');
},
child: Icon(
Icons.cancel,
color: Colors.grey,
),
),
),
border: InputBorder.none,
hintText: 'Search',
hintStyle: TextStyle(color: Colors.grey)),
),
),
Expanded(
child: AzListView(
data: controller.dataList(),
physics: AlwaysScrollableScrollPhysics(),
itemCount: controller.dataList().length,
itemBuilder: (BuildContext context, int index) {
PinYin model = controller.dataList()[index];
return getListItem(context, model);
},
itemScrollController: itemScrollController,
susItemBuilder: (BuildContext context, int index) {
PinYin model = controller.dataList()[index];
return getSusItem(context, model.getSuspensionTag());
},
indexBarOptions: IndexBarOptions(
needRebuild: true,
selectTextStyle: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.w500),
selectItemDecoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xFF333333)),
indexHintWidth: 96,
indexHintHeight: 97,
// indexHintDecoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// Utils.getImgPath('ic_index_bar_bubble_white')),
// fit: BoxFit.contain,
// ),
// ),
indexHintAlignment: Alignment.centerRight,
indexHintTextStyle:
TextStyle(fontSize: 24.0, color: Colors.black87),
indexHintOffset: Offset(-30, 0),
),
),
)
],
),
),
);
}
设置了 resizeToAvoidBottomInset: false
当点击搜索的时候键盘弹出就报底部溢出