1/100DaysOfFlutter : Dart Basics/Final v/s Const
Variables in dart
- var: variable can be reassigned.
- final: variable can not be reassigned.
- const: constant variable.
Different between Final and Const
in a easy way
final name;✅
// you assign value of final after declaration.
name = 'Dart'; ✅
// NOT POSSIBLE WITH DART
const pi;❌
// ERROR: cannot initialize const variable, assign a value to it.
const pi = 3.14;✅
How dart code starts;
void main() {
print('Hello World');
}
in dart code, the Main function is the entry point of the program
1. You wan to print something on the console; start with main().
2. You want to return something; start with main().
3. main() is starting.
What is dart?
Dart is Static language; which meaning everything thing should have a type. Name, Place, Animal, things any things/ everything should have a type.
String name = 10;
int age = 10;
print in dart.
print('1/100DaysOfFlutter : Dart Basics');
String Interpolation in dart
this feature helps us to use variables in dart
void main(){
String name = 'Dart';
print("Hello $name");
}
Taking input in console.
import 'dart:io';
void main(){
stdout.write('Enter your name: ');
String? name = stdin.readLineSync();
// currently ignore "?"
print('Hello $name');
}
Data Types 🙈🙉🙊🐵 in dart:
Number: int, double, num String : String Boolean: bool (True or False) List: List (Array) Map: Map (Dictionary/ Object) Null: null Dynamic: fancyname Void: void/nothing⛔ Function: Function/🤖
🤝🏾Connect me on:
Twitter: 🕊️@Abhayprajapati_
Github: 🐧@theabhayprajapati
Linkedin: 📌@abhayprajaapati
Youtube: 📺@Abhayprajapati