Before Flutter introduced the null-safety feature, I was able to conditionally add Widgets within a list like so:
actions: <Widget>[
canCancel
? CupertinoDialogAction(
child: Text(cancelActionText),
onPressed: () {
Navigator.pop(context);
},
)
: null,
].where(notNull).toList()
notNull
being a homemade filter that filters off the null objects...
Now with null-safety it's impossible because the list of Widgets strictly has to be non-null. What would be a better approach?