This commit is contained in:
Jonas SNK 2025-10-29 22:45:20 +01:00
parent 80b08dafb4
commit 8e56af8bd0

View file

@ -55,7 +55,6 @@ Start Extension in right corner
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
- [online documentation](https://docs.flutter.dev/) - [online documentation](https://docs.flutter.dev/)
# 🧠 Browser Tab Manager - Complete Code Study Guide
## 📋 Table of Contents ## 📋 Table of Contents
1. [App Architecture Overview](#architecture) 1. [App Architecture Overview](#architecture)
@ -110,8 +109,6 @@ void main() {
runApp(const BrowserTabManagerApp()); runApp(const BrowserTabManagerApp());
} }
``` ```
**WHAT HAPPENS HERE:**
1. `main()` is the entry point of every Dart/Flutter app 1. `main()` is the entry point of every Dart/Flutter app
2. `runApp()` tells Flutter to start the app with our root widget 2. `runApp()` tells Flutter to start the app with our root widget
3. Creates the widget tree and starts the rendering engine 3. Creates the widget tree and starts the rendering engine
@ -143,14 +140,14 @@ class BrowserTabManagerApp extends StatelessWidget {
```dart ```dart
class TabData { class TabData {
String id; // Unique identifier String id;
String title; // Display name String title;
String url; // Web address String url;
String favicon; // Icon URL String favicon;
DateTime lastAccessed; // When last used DateTime lastAccessed; // When last used
bool isPinned; // Pinned status bool isPinned;
String type; // 'tab', 'bookmark', or 'history' String type; // 'tab', 'bookmark', or 'history'
int? visitCount; // Number of visits (nullable) int? visitCount; // (nullable)
String? folder; // Bookmark folder (nullable) String? folder; // Bookmark folder (nullable)
} }
``` ```
@ -158,7 +155,6 @@ class TabData {
**PURPOSE:** **PURPOSE:**
- **Data Structure**: Represents all types of browser items uniformly - **Data Structure**: Represents all types of browser items uniformly
- **Type Safety**: Dart ensures correct data types - **Type Safety**: Dart ensures correct data types
- **Nullable Fields**: `?` means the field can be null
### Factory Constructor: ### Factory Constructor:
```dart ```dart
@ -243,7 +239,7 @@ void initState() {
} }
``` ```
**setState()** - The magic that updates UI: **setState()** updates UI:
```dart ```dart
setState(() { setState(() {
allItems = newData; // Change state allItems = newData; // Change state
@ -361,7 +357,7 @@ SearchBar(onChanged: (text) => {
// 3. Parent filters data and updates state // 3. Parent filters data and updates state
void _filterItems() { void _filterItems() {
setState(() => { setState(() => {
filteredItems = // ... filter logic filteredItems = //filter logic
}); });
// 4. Flutter rebuilds UI with new filteredItems // 4. Flutter rebuilds UI with new filteredItems
} }