连续的项目溢出

问题描述 投票:0回答:1

我在列表中有20个项目。我希望每行仅显示3或4个项目(取决于项目的长度)。这是我的代码。 IAM得到的输出是my output screen

 Widget build(BuildContext context) {
    var screenSize = MediaQuery.of(context).size;
    var width = screenSize.width;

    return Scaffold(
      body: Container(
        height: 50,
        width: width,
        color: Theme.of(context).primaryColor,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: List.generate(selectedStudentsIT.length, (index) {
            return Wrap(
              children: <Widget>[
                Container(
                  width: 100,
                  child: Card(
                    color: Colors.white,
                    semanticContainer: true,
                    clipBehavior: Clip.antiAliasWithSaveLayer,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                    elevation: 5,
                    margin: EdgeInsets.all(10),
                    child: Center(
                      child: Text(
                        "myowntext",// item from the list using the index
                        style: TextStyle(
                          color: Colors.blue,
                          fontWeight: FontWeight.bold,
                          fontSize: 15.0,
                        ),
                      ),
                    ),
                  ),
                )
              ],
            );
          }),
        ),
      ),
    );
  }

我已经尝试使用WRAP小部件,Flex并进行了扩展。但这并不能解决我的问题。请帮助。

flutter flutter-layout
1个回答
1
投票

用SingleChlidScrollView包装您的行。

SingleChildScrollView(scrollDirection:Axis.horizontal,child:Row(children......
© www.soinside.com 2019 - 2024. All rights reserved.