💙 Flutter & Dart Mobile Development Masterclass
1️⃣ Flutter Architecture & Impeller Graphics Engine
Definition: Flutter Google dwara banaya gaya ek open-source UI software development kit hai jo single codebase se natively compiled applications (iOS, Android, Web, Desktop) produce karta hai.
| Criteria | Flutter | React Native |
|---|---|---|
| Rendering Engine | Self-Rendered Canvas (Impeller / Skia): Pixel-by-pixel direct hardware rendering. | Native OEM Widgets bridge ke through invoke karta hai. |
| Language | Dart (AOT compiled to native ARM machine code). | JavaScript / TypeScript (JSI runtime engine). |
| Performance | Consistent 60/120 FPS, zero OEM widget styling discrepancies. | High, lekin complex custom animations me bridge coordination lagti hai. |
2️⃣ Dart Programming: Sound Null Safety & OOPs
Dart strong type-safe language hai jo Ahead-of-Time (AOT) aur Just-in-Time (JIT for Hot Reload) dono compile hoti hai:
// 1. Sound Null Safety
String nonNullable = "FresherJobs"; // Never null
String? nullableString; // Can hold null explicitly
// 2. Class with Named Constructor & Initializer
class JobVacancy {
final String title;
final double salary;
JobVacancy({required this.title, required this.salary});
}
// 3. Asynchronous Future Operations
Future<String> fetchUserRole() async {
await Future.delayed(Duration(seconds: 1));
return "Mobile App Lead";
}
3️⃣ The Widget Tree: Stateless vs Stateful Widgets
Flutter me poori UI ek hierarchical Widget Tree hoti hai:
| Widget Type | Characteristics | Standard Use Case |
|---|---|---|
| StatelessWidget | Immutable. Configuration create hone ke baad change nahi hoti. | Static text headers, icons, company logos, read-only cards. |
| StatefulWidget | Mutable. User interaction par setState() call karke build method re-run karta hai. |
Checkboxes, form inputs, dynamic counters, cart items. |
import 'package:flutter/material.dart';
class CounterWidget extends StatefulWidget {
const CounterWidget({super.key});
@override
State<CounterWidget> createState() => _CounterWidgetState();
}
class _CounterWidgetState extends State<CounterWidget> {
int _counter = 0;
void _increment() {
setState(() {
_counter++; // Marks the widget dirty; triggers build()
});
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: _increment,
child: Text("Clicks: $_counter"),
);
}
}
4️⃣ Essential Layout Widgets
- Column: Children ko vertically layout karta hai (Main Axis: Vertical, Cross Axis: Horizontal).
- Row: Children ko horizontally layout karta hai (Main Axis: Horizontal, Cross Axis: Vertical).
- Stack: Children ko ek ke upar ek z-index order me overlap karne deta hai (Floating badges, image overlays).
- Expanded / Flexible: Remaining free available space ko proportionally fill karta hai bina layout overflow ke.
5️⃣ ListView.builder (Lazy Rendering)
Large dynamic data collections ko memory-safe render karna:
ListView.builder(
itemCount: jobsList.length,
itemBuilder: (BuildContext context, int index) {
final job = jobsList[index];
return Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: ListTile(
leading: const Icon(Icons.work, color: Colors.blue),
title: Text(job.title),
subtitle: Text("₹${job.salary} LPA"),
trailing: const Icon(Icons.arrow_forward_ios, size: 14),
onTap: () {
// Push to detail page
},
),
);
},
)
6️⃣ State Management Architecture
| Solution | Complexity | Core Concept |
|---|---|---|
| Ephemerial (setState) | Low | Single screen ke internal widget state ke liye best. |
| Provider | Medium | ChangeNotifier aur InheritedWidget wrapper jo context tree me data propagate karta hai. |
| Riverpod | Medium-High | Compile-safe dependency injection aur reactive provider pattern bina BuildContext dependency ke. |
| BLoC (Business Logic Component) | High | Events and States strictly separated through Reactive Streams (Enterprise apps). |
7️⃣ REST API Integration & FutureBuilder
FutureBuilder<List<JobVacancy>>(
future: apiService.fetchLatestJobs(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Center(child: Text("Error: ${snapshot.error}"));
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
return const Center(child: Text("No vacancies found"));
}
return ListView(
children: snapshot.data!.map((j) => Text(j.title)).toList(),
);
},
)