Hello, the situation I encountered is such that the waterfall will slip and shake when it slides to some position. I hope to get your helpοΌ The code is as follows:
StaggeredGridViewοΌ
return Scaffold(
appBar: _getAppBar(),
body: RefreshLayout(
canloading: isMore,
child: StaggeredGridView.countBuilder(
primary: false,
physics: _isScroll ? ScrollPhysics() : NeverScrollableScrollPhysics(),
padding: EdgeInsets.all(3.0),
itemCount: _list.length,
crossAxisCount: 2,
itemBuilder: (context, index) => SquareItem(index, _list),
staggeredTileBuilder: (index) => StaggeredTile.fit(1),
),
onRefresh: (bool refresh) {
if (refresh) {
return _getListData(0);
} else {
return _getListData(_list[_list.length - 1]['showInfoId']);
}
},
),
);
itemοΌ
class SquareItem extends StatefulWidget {
SquareItem(this._index, this._list);
final List _list;
final int _index;
@OverRide
_SquareItemState createState() => _SquareItemState(_index, _list);
}
class _SquareItemState extends State {
_SquareItemState(this._index, this._list);
final List _list;
final int _index;
Widget _getImgNumGroup() {
return Align(
alignment: Alignment.topRight,
child: Container(
alignment: Alignment.center,
height: 20.0,
width: 51.0,
margin: EdgeInsets.only(right: 8.0, top: 4.0),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.all(Radius.circular(10.0),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Image.asset(Images.image_num),
Text(
'${_list[_index]['imageNum']}εΌ ',
style: TextStyle(
color: Colors.white,
fontSize: 11.0,
),
),
],
),
),
);
}
Widget _getAvatarGroup() {
String avatarUrl = _list[_index]['avatorUrl'];
return Container(
alignment: Alignment.bottomLeft,
margin: EdgeInsets.only(left: 5.0),
child: Row(
children: [
Container(
width: 30.0,
height: 30.0,
child: CircleAvatar(
backgroundImage: avatarUrl != '' && avatarUrl != null ?
CachedNetworkImageProvider(avatarUrl) : AssetImage(Images.head_img),
),
),
],
),
);
}
Widget _getImgBottom() {
bool isShowLive = _list[_index]['livingChannelId'] == 0;
return Container(
margin: EdgeInsets.only(left: 40.0),
alignment: Alignment.bottomCenter,
child: Row(
children: [
Expanded(
child: Text(
_list[_index]['nickName'],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13.0),
),
),
Offstage(
offstage: isShowLive, //trueζ―ιθ
child: Container(
margin: EdgeInsets.only(right: 3.0),
height: 20.0,
alignment: Alignment.centerRight,
child: IconButton(
padding: EdgeInsets.all(0.0),
icon: Image.asset(Images.live_orange),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return LiveRoom();
}));
}
),
),
),
],
),
);
}
Widget _getImgGroup() {
return IntrinsicHeight(
child: Stack(
children: [
Container(
margin: EdgeInsets.only(bottom: 20.0),
child: CachedNetworkImage(
imageUrl: _list[_index]['showImgUrl'],
placeholder: Image.asset(Images.item_placeholder),
errorWidget: Container(
alignment: Alignment.center,
height: 200.0,
child: Icon(Icons.error),
),
),
),
_getImgNumGroup(),
_getAvatarGroup(),
_getImgBottom(),
],
),
);
}
Widget _getContentGroup() {
return Padding(
padding: EdgeInsets.only(left: 5.0, top: 5.0),
child: Text(
widget._list[widget._index]['content'],
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.0,
color: Color(0xff999999),
),
),
);
}
Widget _getBottomGroup() {
return Container(
margin: EdgeInsets.only(left: 5.0, bottom: 3.0),
child: Row(
children: [
Image.asset(Images.follow_num),
Padding(padding: EdgeInsets.only(left: 5.0, right: 10.0), child: Text(_list[_index]['followNum'].toString()),),
Image.asset(Images.playing_num),
Padding(padding: EdgeInsets.only(left: 5.0), child: Text('${_list[_index]['playingNum']}'),),
],
),
);
}
@OverRide
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => SquareDetail(_list[_index]['id'])));
},
child: Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_getImgGroup(),
_getContentGroup(),
_getBottomGroup(),
],
),
),
);
}
}