Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the waterfall slides, it will be stuck. #13

Closed
donghuawei321 opened this issue Jul 11, 2018 · 2 comments
Closed

When the waterfall slides, it will be stuck. #13

donghuawei321 opened this issue Jul 11, 2018 · 2 comments

Comments

@donghuawei321
Copy link

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(),
],
),
),
);
}
}

@letsar
Copy link
Owner

letsar commented Jul 14, 2018

Hi @donghuawei321.
I don't understand what you mean by waterfall. Can you explain it more? Can you make a short video that shows the issue?

If you want me to debug the code, I will need to have access to all the code since I don't know what is RefreshLayout for example.

@letsar
Copy link
Owner

letsar commented Dec 12, 2021

Closing since no response from the OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants