Returns value or run a function based on Platform. If the context is passed, it will get the platform by Theme.of(context).platform. Otherwise, it will use defaultTargetPlatform. "ios", android: "android", fuchsia: "fuchsia", web: "web", defaultWhenNull: "default");

API Reference


On Android, value is primitive types

final result = "value is string");
// result = value is string

On Android, value is a function

final result = () => "value from function");
// result = value from function

On Android, value is not passed, returns null

final result =;
// result = null

On Android, value is not passed and defaultWhenNull is set

final result = "default");
// result = default