简体   繁体   English

我安装了 flutter 搜索字段 0.6.2 package,添加项目时出现错误

[英]I installed the flutter search field 0.6.2 package and I am getting an error while adding the item

I have installed a package to add a dropdownfield to my project, but I want the field to look like in this video .我已经安装了一个 package 来为我的项目添加一个下拉字段,但我希望该字段看起来像这个视频中的那样。 I am getting the below error.我收到以下错误。

//DropdownSearch
                      Container(
                        height: MediaQuery.of(context).size.height * 0.7,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Padding(
                              padding: EdgeInsets.all(20.0),
                              child: Text(
                                'Select a country',
                                style: TextStyle(
                                    fontSize: 16, color: Colors.blueGrey),
                              ),
                            ),
                            Container(
                              child: SearchField(
                                suggestions: [
                                  'Afghanistan',
                                  'Turkey',
                                  'Germany',
                                  'France',
                                  'Italy',
                                  'Spain',
                                  'United Kingdom',
                                  'United States',
                                  'Canada',
                                  'Australia',
                                  'New Zealand',
                                  'India',
                                  'Indonesia',
                                  'Bangladesh',
                                  'Sri Lanka',
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),

Error code:错误代码:

错误代码(图 1)

Error code:错误代码:

错误代码(图 2)

Error message:错误信息:

    The argument type 'List<String>' can't be assigned to the parameter type 'List<SearchFieldListItem<dynamic>>'.dartargument_type_not_assignable
Couldn't infer type parameter 'E'.

-- --

Tried to infer 'String' for 'E' which doesn't work:
  Return type declared as 'List<E>'
              used where  'List<SearchFieldListItem<_>>' is required.
The type 'String' was inferred from:
  Parameter 'element' declared as     'E'
                      but argument is 'String'.

Consider passing explicit type argument(s) to the generic.

The error means that you are passing a List of string into a List that accepts SearchFieldListItem object with a type of dynamic(any type).该错误意味着您将字符串列表传递到接受 SearchFieldListItem object 类型为动态(任何类型)的列表中。 Try to add the items in your list into and List with the given object.尝试使用给定的 object 将列表中的项目添加到列表中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在添加广告时 Flutter 出现错误 - Why I am getting ERROR in Flutter While adding ad 在 Flutter 中,我使用 local_auth 0.6.2+3 package 并实现了示例代码。 单击身份验证按钮时出现以下错误 - In Flutter, I am using local_auth 0.6.2+3 package and implemented the example code. I get the following error when I click the authenticate button 使用 package CarouselSlider 时出现错误,它显示错误类型“图像”不是 flutter 中“字符串”类型的子类型 - I am getting error while using package CarouselSlider it display error type 'Image' is not a subtype of type 'String' in flutter const 列表文字中的值必须是常量,在 Flutter 中将图像添加到列小部件时出现此错误 - The values in a const list literal must be constants, I am getting this error while adding an Image to Column Widget in Flutter 我在尝试运行我的颤振项目时遇到错误 - I am getting error while trying to run my flutter project 在运行颤振应用程序时出现此错误 - while running the flutter app i am getting this error 为什么在更新 flutter sdk 时出现错误? - Why am I getting Error while updating the flutter sdk? 将日期数据上传到 flutter 中的 firestore 时出现错误 - I am getting error while uploading date data to firestore in flutter 在颤振中使用流构建器时出现错误 - I am getting error while using stream builder in flutter 为 iOS 运行 flutter 项目时出现错误 - I am getting error while running the flutter project for iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM