繁体   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

我已经安装了一个 package 来为我的项目添加一个下拉字段,但我希望该字段看起来像这个视频中的那样。 我收到以下错误。

//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',
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),

错误代码:

错误代码(图 1)

错误代码:

错误代码(图 2)

错误信息:

    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.

该错误意味着您将字符串列表传递到接受 SearchFieldListItem object 类型为动态(任何类型)的列表中。 尝试使用给定的 object 将列表中的项目添加到列表中。

暂无
暂无

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

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