getWidgetStateProperty<T> method
Creates a WidgetStateProperty for generic widget properties.
Wraps any widget in a WidgetStateProperty for use with Material widgets that require state-dependent properties. Useful for icons, decorations, etc.
widgetData is the widget to wrap.
defaultValue is an optional fallback widget.
Implementation
WidgetStateProperty<T>? getWidgetStateProperty<T>(
Widget? widgetData, {
Icon? defaultValue,
}) {
if (widgetData == null) {
return null;
}
return WidgetStateProperty.all(widgetData) as WidgetStateProperty<T>?;
}