简体   繁体   中英

Define props with 2 optional types in Dart

In Typescript, I can define a var with 2 types like this

foo: string | number = 'bar'

How can I do the similar in Dart?

You can't do that in dart 2.

Dart 2 is statically typed

https://dart.dev/faq#q-is-dart-a-statically-typed-language

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM