Creating Any Data Types in Dart and Flutter
As we know, all programming languages have some data types. I've been learning dart and as I didn't code much in C or Java, I am not that much familiar with how these actually works.
It has some basic data types like
String
int
bool
etc etc
But, this moring I was working on Stateful Widget in Flutter and I saw this kind of code
So, I dig into this and found that we can create any types. The real thing is when we create _myState Class, it becomes a type.
That's the reason we can use it as type later.
Actually, all types are just types. Even primitive data types like String and int are just classes that are defined in the dart libraries
To see the full discussion: Stack OverFlow
It has some basic data types like
String
int
bool
etc etc
But, this moring I was working on Stateful Widget in Flutter and I saw this kind of code
class MyApp extends StatefulWidget
{
@override
_myState createState() => _myState();
}
class _myState extends State<MyApp> {
...
}
_myState createState() => _myState();
But I couldn't understand. As far as I knew, we use data type beofre a variable or class name [in this case its return type].So, I dig into this and found that we can create any types. The real thing is when we create _myState Class, it becomes a type.
That's the reason we can use it as type later.
Actually, all types are just types. Even primitive data types like String and int are just classes that are defined in the dart libraries
To see the full discussion: Stack OverFlow
Comments
Post a Comment