简体   繁体   中英

How create List button like this Image in flutter

I am confused about using the widget that is most appropriate for this display 在此处输入图片说明

You can use ListTile for each element and Divider between them

ListView.builder(
  itemBuilder: (context, i) {
    if (i.isOdd)
      return Divider();
    final index = i ~/ 2;
    return buildRow(index);
  },
  itemCount: [your_items].length * 2,
  controller: controller,
);

Widget buildRow(int index) {
  return ListTile(
    leading: /* your icon */,
    title: /* title */,
    subtitle: /* subtitle */,
    trailing: /* right arrow */,
  )
}

You can use a ListView widget this is best for this. like so

Scaffold(
        appBar: AppBar(title: Text('Something'),),
        body: ListView(
          children: <Widget>[
            buildListTile(Icons.phone, 'Telepon', "Kode verfikasi akan dikirim melalui telepon", Icons.arrow_forward_ios),
Divider(), // <-- this is added
            buildListTile(Icons.chat_bubble, 'SMS', "Lorem ipsum dolor sit amet, consectetur", Icons.arrow_forward_ios),
Divider(), // <-- this is added
          ],
        ),
      )
    );
  }

  ListTile buildListTile(leadingIcon, titleText, subtitleText, trailingIcon) {
    return ListTile(
            leading: Icon(leadingIcon),
            title: Text(titleText),
            subtitle: Text(subtitleText),
            trailing: Icon(trailingIcon),
          );
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM