Introduction to Dart More Basic To Advance
Flutter development seekhne ke liye hum basic se start karenge aur dheere-dheere advance topics tak pahuchenge. Main aapko
1. Variables and Functions
Variables: Yeh data ko store karne ke liye use hoti hain. Dart me, variables ko declare karne ke liye var, int, double, String etc. use karte hain.
var name = 'John';
int age = 25;
double height = 5.9;
Functions: Yeh reusable code blocks hain jo specific task perform karte hain.
void greet() {
print('Hello!');
}
int add(int a, int b) {
return a + b;
}
2. Decision Making and Loops
Decision Making: Dart me decision making ke liye if, else if, aur else use hota hai.
int age = 20;
if (age > 18) {
print('Adult');
} else {
print('Not an Adult');
}
Loops: Repeat tasks karne ke liye loops use hote hain jaise for, while, do-while.
for (int i = 0; i < 5; i++) {
print(i);
}
int count = 0;
while (count < 5) {
print(count);
count++;
}
3. Strings
Strings text ko represent karte hain. Aap single ya double quotes use karke strings bana sakte hain.
String greeting = 'Hello';
String name = "Alice";
String message = 'Hello, $name!'; // String interpolation
4. More Advance Dart
Isme aapko Dart ke kuch advance concepts jaise async programming, collections (List, Set, Map), futures, streams etc. samajhne padenge.
List: Ordered collection hai.
List<int> numbers = [1, 2, 3, 4];
Map: Key-value pairs hoti hain.
领英推荐
Map<String, int> ages = {'Alice': 25, 'Bob': 30};
5. Continue and Break
Loops me continue aur break use hota hai to control the flow.
for (int i = 0; i < 5; i++) {
if (i == 2) continue; // Skip this iteration
if (i == 4) break; // Exit the loop
print(i);
}
6. Final and Const Keyword
Final: Run-time constant hai, value assign hone ke baad change nahi ho sakti.
final name = 'John';
Const: Compile-time constant hai, aur ye value compile hone ke time pe hi fix ho jati hai.
const pi = 3.14;
7. Object-Oriented Programming
OOP concepts jaise classes, objects, inheritance, polymorphism Dart me important hain.
class Animal {
String name;
Animal(this.name);
void speak() {
print('$name makes a sound');
}
}
class Dog extends Animal {
Dog(String name) : super(name);
@override
void speak() {
print('$name barks');
}
}
void main() {
Dog dog = Dog('Rex');
dog.speak(); // Rex barks
}
8. Exception Handlings
Exceptions unexpected errors ko handle karne me help karti hain.
dart
try {
int result = 10 ~/ 0;
} catch (e) {
print('Error: $e');
} finally {
print('This will always execute');
}
9. Understand Flutter IDE
Flutter development ke liye aapko IDE (Integrated Development Environment) jaise Android Studio ya Visual Studio Code ka use karna hoga. IDE me aap Flutter plugins install kar sakte hain jo development ko easy banata hai. Aap yahan project create, debug aur run kar sakte hain.
Ab aapko in topics ke baare me kuch idea ho gaya hoga. Flutter me practice aur projects banake aap apni skills ko aur enhance kar sakte hain. Happy coding!