- Published
- Author
- Sujay
Difference between dynamic and Object type in dart
dynamic : dynamic is incredibly flexible. It tells Dart compiler to skip the type checking at compile time while type checking happens at run time. This is helpful when working with data of uncertain types.dart
dynamic value = 42;
value = 'Sujay';
print(value.isEven); // Error thrown during runtimeObject : Object is the root class for all other classes. Its like a container like that can hold any value. Since Object is generic, you won't have access to specific methods or properties of value without type castingCode
Object value = 42;
print(value.isEven); // throws compile time error