新建项目-3.png

    • 当使用Row 时,宽度超过屏幕宽时,超过部分无法显示。
    • 使用Wrap时,超过屏幕宽度时,自动换行。
    • 可以水平使用,也可以垂直使用
    1. ap({
    2. Key key,
    3. this.direction = Axis.horizontal, // 水平或垂直
    4. this.alignment = WrapAlignment.start, // 对齐方式
    5. this.spacing = 0.0, // 子widget之间的间距,水平间距或垂直间距
    6. this.runAlignment = WrapAlignment.start, // 纵轴方向的对齐方式
    7. this.runSpacing = 0.0, // 纵轴方向的间距
    8. this.crossAxisAlignment = WrapCrossAlignment.start,
    9. this.textDirection,
    10. this.verticalDirection = VerticalDirection.down,
    11. List<Widget> children = const <Widget>[],
    12. })

    属性大部分都喝Row是一样的.就不记录了. 写个demo:

    1. Container(
    2. color: Colors.amber,
    3. height: 200,
    4. child: Wrap(
    5. spacing: 5, //水平间距
    6. runSpacing: 5, //垂直间距
    7. children: <Widget>[
    8. Image.network(
    9. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=4032780575,3204528048&fm=26&gp=0.jpg",
    10. width: 100,
    11. height: 100,
    12. ),
    13. Image.network(
    14. "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1063547563,2289391090&fm=26&gp=0.jpg",
    15. width: 100,
    16. height: 100,
    17. ),
    18. Image.network(
    19. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586237355792&di=4f65876fc2cb9e572c5b67e5494528c6&imgtype=0&src=http%3A%2F%2Fimg3.duitang.com%2Fuploads%2Fitem%2F201605%2F13%2F20160513184344_LviPQ.jpeg",
    20. width: 100,
    21. height: 100,
    22. ),
    23. Image.network(
    24. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1249774586,3389422086&fm=26&gp=0.jpg",
    25. width: 100,
    26. height: 100,
    27. ),
    28. Image.network(
    29. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586237371895&di=adf6082c8fcc78289cce9624d7bff576&imgtype=0&src=http%3A%2F%2Fwww.17qq.com%2Fimg_qqtouxiang%2F87354522.jpeg",
    30. width: 100,
    31. height: 100,
    32. ),
    33. Image.network(
    34. "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586237371898&di=1b7029b71f3a9c3caa7e9e4bace0c7e0&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201509%2F29%2F20150929012659_QmNZh.jpeg",
    35. width: 100,
    36. height: 100,
    37. ),
    38. ],
    39. ),
    40. ),

    image.png

    1. Container(
    2. color: Colors.amber,
    3. height: 200,
    4. child: Wrap(
    5. children: <Widget>[
    6. Chip(
    7. backgroundColor: Colors.blue,
    8. label: Text("北京",style: TextStyle(color: Colors.white),),
    9. avatar: Icon(Icons.location_city,color: Colors.white,),
    10. ),
    11. Chip(
    12. backgroundColor: Colors.blue,
    13. label: Text("上海",style: TextStyle(color: Colors.white),),
    14. avatar: Icon(Icons.location_city,color: Colors.white,),
    15. ),
    16. Chip(
    17. backgroundColor: Colors.blue,
    18. label: Text("济南",style: TextStyle(color: Colors.white),),
    19. avatar: Icon(Icons.location_city,color: Colors.red,),
    20. ),
    21. Chip(
    22. backgroundColor: Colors.blue,
    23. label: Text("泰安",style: TextStyle(color: Colors.white),),
    24. avatar: Icon(Icons.location_city,color: Colors.white,),
    25. ),
    26. Chip(
    27. backgroundColor: Colors.blue,
    28. label: Text("菏泽",style: TextStyle(color: Colors.white),),
    29. avatar: Icon(Icons.location_city,color: Colors.white,),
    30. ),
    31. Chip(
    32. backgroundColor: Colors.blue,
    33. label: Text("济宁",style: TextStyle(color: Colors.white),),
    34. avatar: Icon(Icons.location_city,color: Colors.white,),
    35. onDeleted: () {
    36. print(123333);
    37. },
    38. ),
    39. Chip(
    40. backgroundColor: Colors.blue,
    41. label: Text("广东",style: TextStyle(color: Colors.white),),
    42. avatar: Icon(Icons.location_city,color: Colors.white,),
    43. ),
    44. Chip(
    45. backgroundColor: Colors.blue,
    46. label: Text("纽约",style: TextStyle(color: Colors.white),),
    47. avatar: Icon(Icons.location_city,color: Colors.white,),
    48. ),
    49. Chip(
    50. backgroundColor: Colors.blue,
    51. label: Text("洛杉矶",style: TextStyle(color: Colors.white),),
    52. avatar: Icon(Icons.location_city,color: Colors.white,),
    53. ),
    54. Chip(
    55. backgroundColor: Colors.blue,
    56. label: Text("大宁阳",style: TextStyle(color: Colors.white),),
    57. avatar: Icon(Icons.location_city,color: Colors.white,),
    58. onDeleted: () {
    59. print(123333);
    60. },
    61. ),
    62. ],
    63. ),
    64. ),

    image.png