GFDropdown
Not996NotOT opened this issue · 9 comments
The following _TypeError was thrown building GFDropdown(dirty, state:
_GFDropdownState#682b8):
type '(String?) => void' is not a subtype of type '((dynamic) => void)?'
I did have the same error
hi @Not996NotOT
Can you please show the more code as this looks more about the state issue, also tell me the flutter version and getwidget version you are using.
Thank you.
The following _TypeError was thrown building GFDropdown(dirty, state: _GFDropdownState#682b8): type '(String?) => void' is not a subtype of type '((dynamic) => void)?'
hi @Not996NotOT ,
I have identified the issue please wait.
Hi @Not996NotOT @true-glassy
We have fixed the issue, for now you can use
I also got same error can u please update on pub.dev
@PremchandGat
Thank you for update, we will do it in the next version.
The solution is to change
class GFDropdown<T> extends StatefulWidget {
// ...
_GFDropdownState createState() => _GFDropdownState();
}
class _GFDropdownState extends State<GFDropdown> {
// ...
}
to
class GFDropdown<T> extends StatefulWidget {
// ...
State<GFDropdown<T>> createState() => _GFDropdownState(); // Specify type parameter
}
class _GFDropdownState<T> extends State<GFDropdown<T>> { // Specify type parameter twice
// ...
}
I have the same problem, it looks like <T>
wasn't passed to DropdownButton so it was expecting dynamic.
Yet i couldn't try but I think if <T>
passed the DropdownButton it will be ok.
//...
State<GFDropdown<T>> createState() => _GFDropdownState();
//...
class _GFDropdownState<T> extends State<GFDropdown<T>> {
@override
Widget build(BuildContext context) => Material(
color: widget.dropdownButtonColor,
shape: RoundedRectangleBorder(
side: widget.border,
borderRadius: widget.borderRadius,
),
child: Container(
height: widget.itemHeight,
padding: widget.padding,
child: DropdownButton<T>(
items: widget.items,
selectedItemBuilder: widget.selectedItemBuilder,
value: widget.value,
hint: widget.hint,
disabledHint: widget.disabledHint,
onChanged: widget.onChanged,
onTap: widget.onTap,
elevation: widget.elevation,
style: widget.style,
icon: widget.icon,
iconDisabledColor: widget.iconDisabledColor,
iconEnabledColor: widget.iconEnabledColor,
iconSize: widget.iconSize,
isDense: widget.isDense,
isExpanded: widget.isExpanded,
// itemHeight: widget.itemHeight,
focusColor: widget.focusColor,
focusNode: widget.focusNode,
autofocus: widget.autofocus,
dropdownColor: widget.dropdownColor,
),
),
);
}
Until this will be fixed you can use GFDropdown with dynamic generic like GFDropdown<dynamic>
in your widget tree.
please use latest version,we have resolved the issue