I have installed a package to add a dropdownfield to my project, but I want the field to look like in this video . 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:
Error code:
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). Try to add the items in your list into and List with the given object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.