My api return number if data exists in database, or return null if don't exists.
child: DropdownButton<String>(
hint: new Text("Select"),
value: widget.car.type.toString(),
When data exists default value work fine, but when data is null get error:
There should be exactly one item with [DropdownButton]'s value: null.
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value
'package:flutter/src/material/dropdown.dart':
Failed assertion: line 850 pos 15: 'items == null || items.isEmpty || value == null ||
items.where((DropdownMenuItem<T> item) {
return item.value == value;
}).length == 1'
Any solution how solve this problem, if value is null.
When put value: null, work but for all item must select item from list.
IS it possible here value: widget.car.type.toString(),
some like this is it possible:
value: widget.car.type.toString() ?? null,