小编JeC*_*eCr的帖子

如何在 Flutter 中使用 ChoiceChip 创建带有自定义标签的包装

我正在学习颤振,但有些东西我在任何地方都找不到。

比如我想做一组 ChoiceChips,类似图片

在此输入图像描述

但我不知道如何在这种芯片上贴上自定义标签。

我怎样才能使它成为可能?

 import 'package:flutter/material.dart';

 class MyThreeOptions extends StatefulWidget {
  @override
   _MyThreeOptionsState createState() => _MyThreeOptionsState();
}

  class _MyThreeOptionsState extends State<MyThreeOptions> {
  int _value = 0;

  // ----What I want to appear----//
  /*void v (int index){
   switch (index){
   case 0: Text('Phones');
   break;

   case 1: Text('Computers');
   break;

   case 2: Text('Accessories');
   break;
   }}*/

  @override
  Widget build(BuildContext context) {
  return Wrap(
  alignment: WrapAlignment.center,
  spacing: 12.0,
  children: List<Widget>.generate(
  3,
      (int index) {
      return ChoiceChip(
       pressElevation: 0.0,
       selectedColor: Colors.blue, …
Run Code Online (Sandbox Code Playgroud)

android-chips flutter

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

android-chips ×1

flutter ×1