4 /100DaysOfFlutter : Dart: List, Classes and Objects

4 /100DaysOfFlutter : Dart: List, Classes and Objects

Learn Dart Classes and Objects

ยท

2 min read

Dart List: List<String> skills = ['Swiming', 'running', 'Karate']

This line will be spoken as List of String named skills has values Swiming running Karate; you can also use your own way of reading and pronouncing it.

List can also be called an array.

a list can contain only one data type of element. for multiple types of elements, we can use something called Objects in the list.

Classes: Classes give usability to make their own type of data, a sort of template, protocol, the rule for some Objects/ Variables.

class Insan extends LivingThings {
  String name;
  int age;
  Insan(this.name, this.age);
}

Now I can use these data types to make my own variables with these data types.

  Insan Abhay = new Insan("Abhay", 19);

as before Insan is the type of variable, Abhay is the variable name ๐Ÿ†• keyword is for before it is new Variables made which has a combination of data types/ mostly new key used when for a single variable we use multiple datatypes. Like, here we are using String and int at the same time passing the parameter's in the Class

Objects: Objects gives the ability to make the variables the classes we make,

in reality, anything that takes place, area, memory is a Object as the Variable named Abhay which is created above is going to take place in the memory then it is an Object, Object has type can your own type also, Like Insan

  Insan Abhay = new Insan("Abhay", 19);

Objects is also known as Instances; you can check by your self just printing the Variable name

print(Abhay);
//Instance of 'Insan'

Making classes helps us to make better Objects; classes are created outside of the Function

Check The code here with example press . and open the in the browser and start practising.

If don't got at some point feel free to ping me on Twitter @abhayprajapati_

Ok Bye.

Did you find this article valuable?

Support @Abhay's Blog by becoming a sponsor. Any amount is appreciated!

ย