maybe_as 0.0.1 copy "maybe_as: ^0.0.1" to clipboard
maybe_as: ^0.0.1 copied to clipboard

outdated

Optional as. Returns null if type if not match the class type.

Info #

Optional as. maybeAs returns the current object if the type is the same and null otherwise
maybeAsOr returns the current object or default value
so it safe to use on dynamic fields and avoid constructions like this

dynamic object = 1;
object is String ? object : null;
object is String ? object : "test";
object != null ? object : "test"

Example #

"1".maybeAs

1.maybeAs

"1".maybeAsOr

1.maybeAsOr

it also works with null

null.maybeAsOr

5
likes
0
points
33
downloads

Publisher

verified publisherpub.iostech.org

Weekly Downloads

Optional as. Returns null if type if not match the class type.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on maybe_as