[英]Define props with 2 optional types in Dart
In Typescript, I can define a var with 2 types like this在打字稿中,我可以像这样定义一个有 2 种类型的 var
foo: string | number = 'bar'
How can I do the similar in Dart?我怎样才能在 Dart 中做类似的事情?
You can't do that in dart 2.你不能在飞镖 2 中做到这一点。
Dart 2 is statically typed
Dart 2 是静态类型的
https://dart.dev/faq#q-is-dart-a-statically-typed-language https://dart.dev/faq#q-is-dart-a-statically-typed-language
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.