如何在Flutter中制作带有圆形项目的ListView或目录

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

我如何列出带有此图像的子类别的itemCategories列表,任何建议

谢谢

enter image description here

flutter flutter-layout
1个回答
0
投票

您可以检查以下使用Wrap小部件的示例

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: MyWidget(),
    ),
  );
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var data = [
      {'name': 'Shopping', 'color': Colors.blue, 'icon': Icons.local_shipping},
      {'name': 'Service', 'color': Colors.red, 'icon': Icons.room_service},
      {'name': 'Hotel', 'color': Colors.green, 'icon': Icons.hotel},
      {'name': 'More', 'color': Colors.amber, 'icon': Icons.more},
      {'name': 'Custom', 'color': Colors.orange, 'icon': Icons.add_to_photos},
    ];
    return Scaffold(
        body: Center(
            child: Wrap(
                alignment: WrapAlignment.center,
                spacing: 8.0, // gap between adjacent chips
                runSpacing: 4.0, // gap between lines
                children: data
                    .map((e) => Column(
                          children: <Widget>[
                            ClipOval(
                              child: Container(
                                color: e["color"],
                                child: SizedBox(
                                    width: 50,
                                    height: 50,
                                    child: Icon(
                                      e["icon"],
                                      color: Colors.white,
                                      size: 30,
                                    )),
                              ),
                            ),
                            Text(e["name"])
                          ],
                        ))
                    .toList())));
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.