2

我需要在我的应用程序中使用标签。为此,我找到了 flutter_tagging 库。我的问题是,当我单击按钮时,我不知道如何清除选定的标签。

FlutterTagging(
     textFieldDecoration: InputDecoration(
         border: OutlineInputBorder(),
         hintText: "Tags",
         labelText: "Enter tags"),
     addButtonWidget: _buildAddButton(),
     chipsColor: Colors.pinkAccent,
     chipsFontColor: Colors.white,
     deleteIcon: Icon(Icons.cancel,color: Colors.white),
     chipsPadding: EdgeInsets.all(2.0),
     chipsFontSize: 14.0,
     chipsSpacing: 5.0,
     chipsFontFamily: 'helvetica_neue_light',
     suggestionsCallback: (pattern) async {
       return await TagSearchService.getSuggestions(pattern);
       },
     onChanged: (result) {
       setState(() {
         text = result.toString();
         });
       },
)
4

1 回答 1

1

我在这里看到两个选项:

  1. Fork 库并添加将清除Map _selectedTagValues变量的方法。
  2. 在您的小部件中启动Key taggingKey = UniqueKey()UniqueKey),将其传递给FlutterTaggingkey.currentState.reset()在您必须重置它并使用其初始状态重建整个 FlutterTagging 小部件时调用。
于 2019-07-26T08:30:04.747 回答