Welcome to Flutter Basics! 🦋
Hello everyone and welcome to today's GDG Jammu workshop! Whether you have never written a line of Flutter code or just getting started — this workshop is designed just for you. We will learn step-by-step, no prior Flutter knowledge required.
Session 1
Understand how Flutter works under the hood — architecture, widgets, and rendering
Session 2
Build a real "Brew Café" app together — live coding from scratch
Session 3
Use Antigravity AI to build features 10x faster — live demo
What You Need Today
Before we start, make sure you have the following ready on your laptop:
Flutter SDK
Download from flutter.dev. Run flutter doctor in your terminal — you should see checkmarks ✅.
VS Code + Flutter Extension
Install VS Code from code.visualstudio.com, then install the Flutter and Dart extensions from the marketplace.
A Device or Emulator
Connect your Android phone (enable USB debugging) or set up an Android/iOS emulator in your IDE.
About GDG Jammu 🌟
Google Developer Groups (GDG) are community-run groups for people who are interested in Google's developer technology. GDG Jammu is the local chapter bringing developers, designers, and tech enthusiasts together through workshops, talks, and events like this one.
Today's workshop is organized by Atul Sharma, GDG Jammu organizer and full-stack developer, to make Flutter accessible to every developer in Jammu.
How Flutter Works 🏗️
Before we write any code, let's understand what Flutter actually is and how it works. This will help everything else make sense.
What Is Flutter?
Flutter is Google's free, open-source toolkit that lets you build beautiful apps for Android, iOS, Web, and Desktop — all from a single codebase written in the Dart programming language.
| Without Flutter | With Flutter |
|---|---|
| Separate code for Android (Java/Kotlin) | One Dart codebase for everything |
| Separate code for iOS (Swift) | Same UI on all platforms |
| Different design languages per OS | Consistent, beautiful design everywhere |
| 2-3x more development time | Build once, ship everywhere 🚀 |
Flutter's Architecture — The 3 Layers
Flutter has three layers, each doing a different job. Think of it like a restaurant:
Your App (Dart Code) — The Customer's Order
This is the code you write. You describe what you want (buttons, text, images) using widgets.
Flutter Framework — The Kitchen
Flutter takes your description and figures out exactly how to display it — layout, animations, gestures. This is written in Dart.
Flutter Engine (C++) — The Chef Drawing on the Screen
The engine uses the Skia / Impeller graphics library to literally paint every pixel on the screen. It does NOT use Android or iOS buttons — it draws its own.
Everything is a Widget
In Flutter, every single thing you see is a Widget. A widget is just a Dart class that describes a piece of your UI.
Text
A widget that shows text
Container
A box that holds other widgets
Column
Stacks widgets vertically
ElevatedButton
A tappable button widget
Two Types of Widgets
| StatelessWidget | StatefulWidget |
|---|---|
| Doesn't change over time | Can change when something happens |
| Like a printed poster | Like a live scoreboard |
| Examples: Text, Icon, Image | Examples: Checkbox, Counter, Search bar |
| Simpler and faster | Use when you need interactivity |
Your First Widget — Hello Flutter!
Let's see a real example. Here is the smallest complete Flutter app possible:
// This imports all Flutter UI tools
import 'package:flutter/material.dart';
// main() is where your app starts — just like in other languages
void main() {
runApp(const MyApp()); // Tell Flutter to run our app
}
// Our app is itself a Widget!
class MyApp extends StatelessWidget {
const MyApp({super.key});
// build() describes what this widget looks like
@override
Widget build(BuildContext context) {
return MaterialApp( // Sets up the app shell
home: Scaffold( // Provides the basic page structure
appBar: AppBar(
title: const Text('👋 My First App'), // The top bar text
),
body: const Center( // Centers its child on screen
child: Text(
'Hello, GDG Jammu! 🚀',
style: TextStyle(fontSize: 24),
),
),
),
);
}
}
Breaking It Down — Line by Line
import 'package:flutter/material.dart'
This loads all of Flutter's ready-made widgets (like Text, Button, Column) so you can use them. Like adding ingredients to your kitchen.
void main() { runApp(...) }
Every Dart program starts from main(). runApp() tells Flutter "start showing this widget on screen!"
class MyApp extends StatelessWidget
We're creating a new widget class called MyApp. It extends StatelessWidget, meaning it won't change after it's built.
Widget build(BuildContext context)
Flutter calls this method to ask "what does this widget look like right now?". You return a description of the UI.
🧠 Quick Check — Did You Understand?
- What are the two types of widgets? When would you use each?
- Flutter draws its own pixels — what does this mean for cross-platform apps?
- What method must every widget have?
Build Brew Café ☕
Now let's put everything we learned into practice! We'll build a real coffee ordering app together — from absolute zero to a working, beautiful app.
Step 1 — Create the Project
Open your terminal and run:
flutter create brew_cafe
cd brew_cafe
code .
This creates a new Flutter project and opens it in VS Code. You'll see a lib/main.dart file — that's where we start!
Step 2 — Project Structure
Good apps keep code organized. We'll create these folders inside lib/:
lib/
├── main.dart ← App entry point + theme
├── models/
│ └── coffee.dart ← Coffee data model
├── screens/
│ ├── home_screen.dart ← Welcome page
│ └── menu_screen.dart ← Menu + cart
└── widgets/
└── coffee_card.dart ← Reusable card UI
Step 3 — The Coffee Model
A "model" is a Dart class that represents real-world data. Our Coffee model stores everything about a single drink:
// lib/models/coffee.dart
class Coffee {
final String name; // e.g. "Espresso"
final String description; // e.g. "Strong and bold"
final double price; // e.g. 3.99
final String emoji; // e.g. "☕"
// 'const' constructor — data that never changes
const Coffee({
required this.name, // 'required' means you MUST provide this
required this.description,
required this.price,
required this.emoji,
});
}
// Our menu — a list of Coffee objects
final List<Coffee> cafeMenu = [
const Coffee(name: 'Espresso', description: 'Strong and bold single shot', price: 3.99, emoji: '☕'),
const Coffee(name: 'Cappuccino', description: 'Espresso with steamed milk foam', price: 4.99, emoji: '🥛'),
const Coffee(name: 'Latte', description: 'Smooth espresso with lots of milk',price: 5.49, emoji: '🧋'),
const Coffee(name: 'Mocha', description: 'Chocolate meets coffee heaven', price: 5.99, emoji: '🍫'),
const Coffee(name: 'Cold Brew', description: 'Slow-steeped for smooth flavor', price: 4.49, emoji: '🧊'),
const Coffee(name: 'Matcha', description: 'Premium Japanese green tea', price: 5.99, emoji: '🍵'),
];
Step 4 — The Cart (State Management)
Here's the most important concept in this session: mutable state. The cart changes when users tap "Add" — so we need a StatefulWidget.
class _MenuScreenState extends State<MenuScreen> {
// Map: coffee name → how many in cart
// e.g. {'Espresso': 2, 'Latte': 1}
final Map<String, int> _cart = {};
// Getter: total number of items
int get totalItems => _cart.values.fold(0, (sum, n) => sum + n);
void _addToCart(Coffee coffee) {
setState(() {
// If not in cart yet, start at 0, then add 1
_cart[coffee.name] = (_cart[coffee.name] ?? 0) + 1;
});
// setState() ← This is the MAGIC. It tells Flutter:
// "Something changed! Rebuild the UI!"
}
}
setState(() { ... }). Without it, Flutter won't know to redraw the screen.Step 5 — Navigation Between Screens
Flutter uses a Navigator (like a stack of pages) to move between screens:
// PUSH — go to a new screen (adds it on top of the stack)
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const MenuScreen()),
);
// POP — go back (removes the top screen from the stack)
Navigator.pop(context);
🏋️ Mini Challenges
- Easy: Add a 7th drink to the
cafeMenulist. - Medium: Add a remove (-) button so users can decrease quantity.
- Hard: Show a "Your cart is empty" message when no items are added.
Antigravity for Flutter 🤖
Antigravity is an AI coding assistant built by Google DeepMind. It lives inside your VS Code and understands your entire project — helping you write, debug, and improve Flutter code at incredible speed.
What Can Antigravity Do?
Write Code
Generate entire screens, widgets, models from a description
Fix Bugs
Paste an error and get an instant fix with explanation
Refactor
Improve your code structure without breaking anything
Generate Tests
Write widget and unit tests automatically
Run Commands
Add packages, run builds, analyze code for you
Explain Code
Ask "what does this do?" and get a plain-English answer
Example Prompts to Try Right Now
During this workshop, try these exact prompts in Antigravity:
Tips for Great Results
| ❌ Vague Prompt | ✅ Better Prompt |
|---|---|
| "add search" | "Add a search TextField at the top of MenuScreen that filters cafeMenu by name" |
| "fix my code" | "Fix the setState() call in _MenuScreenState — it's not updating the cart count badge" |
| "make a model" | "Create a User model with id, name, email, and joinedAt fields, include fromJson and toJson methods" |
🎯 Live Demo: Ask Antigravity to Build a Feature
Let's do this together! We'll ask Antigravity to add a Favorites feature to Brew Café:
Watch Antigravity handle multiple files, new dependencies, state management, and animations — all in one shot!
🎉 Workshop Complete!
Congratulations on completing the GDG Jammu Flutter Basics Workshop! Here's what you learned today:
| Session | Key Takeaway |
|---|---|
| 🏗️ Session 1 | Flutter draws its own pixels — widgets, three trees, hot reload |
| ☕ Session 2 | Real apps use models, screens, widgets + setState for interactivity |
| 🤖 Session 3 | Antigravity AI makes you 10x faster — be specific in your prompts |