Everything expands to screenwidth inside a Listview. Can I change that?

前端 未结 5 2268
深忆病人
深忆病人 2021-02-13 11:59

I\'m trying to make a design of a chat screen for an app that I\'m making. To make it scrollable I placed all the chat messages inside a listview. But everything I place inside

5条回答
  •  逝去的感伤
    2021-02-13 12:11

    Thanks for the answers. This one helped me a bit more:

    flutter ListView children size

    I ended up with code like this:

      var sizeW = MediaQuery.of(context).size.width;
      var leftCut = 0.0;
      var rightCut = 0.0;
      if (sizeW > WEB_MAX_WIDTH) {
        leftCut = (sizeW - WEB_MAX_WIDTH) / 2;
        rightCut = leftCut;
      }
    

    And then use those like this:

              return Container(
                margin: EdgeInsets.only(right:rightCut, left: leftCut),
                  padding:
                      EdgeInsets.only(left: (_fullList[index].level * 30.0)),
                  child: Card(
                      child: ListTile(
                    ...
    

提交回复
热议问题