首页 > 解决方案 > 如何在颤动中使用while或for创建按钮?

问题描述

我想根据排列的长度制作按钮。但我不知道,因为我是颤振的首发。

Widget menubar = Center(
          child: Container(
            padding: const EdgeInsets.all(20),
            child: Row(
              children: <Widget>[
                // I want make some button here button number is 10
              ],
             ),//Row
            ),//Container
           );//Center

标签: flutterdart

解决方案


我不知道我是否完全理解你,但也许你可以试试这个:

Widget menubar = Center(
    child: Container(
      padding: const EdgeInsets.all(20),
      child: Row(
        children: List.generate(10, (index) => RaisedButton(
          child: Text("Button number $index"),
        )),
      ),//Row
    ),//Container
  );//Center

推荐阅读