如果我的容器没有达到7高度,我的容器就会弹出屏幕,但是我希望它自动出现在屏幕的尽头,我该怎么做?
new Container(
//height: 500.0,
child: RefreshIndicator(
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
primary: true,
//physics: BouncingScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0),
itemCount: contacts.length,
itemBuilder: (context, index) {
return CardItem(
item: index,
contacts: contacts,
onTap: () {
setState(() {
_selectedItem = contacts[index].name == _selectedItem
? null : contacts[index].name;
});
},
selected: _selectedItem == contacts[index].name,
);
},
),
onRefresh: _handleRefresh,
),
);
答案 0 :(得分:0)
使用Mediaquery:
new Container(
height: MediaQuery.of(context).size.height,
child: RefreshIndicator(
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
primary: true,
//physics: BouncingScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0),
itemCount: contacts.length,
itemBuilder: (context, index) {
return CardItem(
item: index,
contacts: contacts,
onTap: () {
setState(() {
_selectedItem = contacts[index].name == _selectedItem
? null : contacts[index].name;
});
},
selected: _selectedItem == contacts[index].name,
);
},
),
onRefresh: _handleRefresh,
),
);
答案 1 :(得分:0)
将您的容器放入SingleChildScrollView中,为
new SingleChildScrollView(child: new Container(
//height: 500.0,
child: RefreshIndicator(
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
primary: true,
//physics: BouncingScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0),
itemCount: contacts.length,
itemBuilder: (context, index) {
return CardItem(
item: index,
contacts: contacts,
onTap: () {
setState(() {
_selectedItem = contacts[index].name == _selectedItem
? null : contacts[index].name;
});
},
selected: _selectedItem == contacts[index].name,
);
},
),
onRefresh: _handleRefresh,
),
),scrollDirection: Axis.vertical,)