Get Started with Flutter App Development
One Codebase, Multiple Platforms: Write code once for Android, iOS, web, and desktop.
Fast Development: Features like Hot Reload let you see changes instantly without losing app state.
Expressive UI: Build beautiful, custom user interfaces easily with a rich set of widgets.
Native Performance: Compiles directly to machine code, delivering excellent performance.
You'll need Node.js, Git, Flutter SDK, and an IDE.
Install Node.js & npm (if not already installed): Essential for many development tools. Download from nodejs.org.
Install Git: Download from git-scm.com.
Download Flutter SDK:
Choose your OS (Windows, macOS, Linux) and download the latest stable release.
Extract the flutter.zip (or .tar.xz) file to a non-privileged location (e.g., C:\src\flutter on Windows, ~/development/flutter on macOS/Linux). Do NOT extract to Program Files.
Update your PATH Environment Variable:
Add the bin folder of your Flutter SDK to your system's PATH. (e.g., C:\src\flutter\bin).
Windows: Search "env" -> "Edit system environment variables" -> "Environment Variables..." -> Under "User variables", edit "Path" -> "New" -> Add your path.
macOS/Linux: Edit ~/.zshrc or ~/.bashrc: export PATH="$PATH:[path_to_flutter_directory]/bin". Then source ~/.zshrc or source ~/.bashrc.
Run flutter doctor: Open a new terminal/command prompt and type:
flutter doctor
This checks your setup. It will likely tell you to install Android Studio (for Android dev) and Xcode (for iOS dev on macOS). Follow its instructions to install missing components and accept licenses (flutter doctor --android-licenses).
Install VS Code (Recommended IDE):
Download from code.visualstudio.com.
Open VS Code, go to Extensions (Ctrl+Shift+X or Cmd+Shift+X), search for "Flutter", and install it. This will also install the "Dart" extension.
Everything is a Widget: In Flutter, UI is built entirely from widgets. A widget is a building block that describes a part of the UI.
Widget Tree: Your entire app's UI is a nested tree of widgets.
StatelessWidget: For UI parts that don't change after they are built (e.g., a static text label, an icon).
StatefulWidget: For UI parts that do change over time (e.g., a button that changes text, a counter). It has a State object that holds mutable data.
setState(): The magic function for StatefulWidgets. Call this to tell Flutter that your widget's internal state has changed, and it needs to rebuild its UI.
Hot Reload: A super-fast way to see changes in your code instantly without losing the current app state. Just save your file!
Hot Restart: Resets the app to its initial state and re-runs main(). Useful for changes that affect the app's fundamental structure.
Let's create a basic app that increments a number when a button is pressed.
Create a new Flutter project: Open your terminal and run:
flutter create my_counter_app
cd my_counter_app
Open the project in VS Code:
code .
You'll see a pre-generated main.dart file. Let's simplify and understand it.
Replace the content of lib/main.dart with this simplified code:
import 'package:flutter/material.dart';
void main() {
// runApp starts the Flutter app by displaying the given widget.
runApp(const MyApp());
}
// MyApp is a StatelessWidget, as it just sets up the basic app structure (MaterialApp).
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Simple Counter App',
theme: ThemeData(
primarySwatch: Colors.blueGrey, // A primary color for your app
),
home: const CounterScreen(), // Our main screen
);
}
}
// CounterScreen is a StatefulWidget because its state (the counter value) changes.
class CounterScreen extends StatefulWidget {
const CounterScreen({super.key});
@override
State<CounterScreen> createState() => _CounterScreenState();
}
// This is the mutable State class associated with CounterScreen.
class _CounterScreenState extends State<CounterScreen> {
int _counter = 0; // Our state variable, initialized to 0
// This method updates the counter and tells Flutter to rebuild the UI.
void _incrementCounter() {
setState(() { // Call setState to notify Flutter of a state change
_counter++; // Increment the counter
});
}
@override
Widget build(BuildContext context) {
// Scaffold provides the basic visual structure of a Material Design screen.
return Scaffold(
appBar: AppBar(
title: const Text('My Counter App'),
backgroundColor: Theme.of(context).primaryColor, // Use the primary color from theme
),
body: Center( // Centers its child widget
child: Column( // Arranges children vertically
mainAxisAlignment: MainAxisAlignment.center, // Center vertically
children: <Widget>[
const Text(
'You have pushed the button this many times:',
style: TextStyle(fontSize: 18), // A simple style
),
Text(
'$_counter', // Display the current counter value
style: const TextStyle(fontSize: 48, fontWeight: FontWeight.bold),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter, // Call our method when the button is pressed
tooltip: 'Increment',
child: const Icon(Icons.add), // An 'add' icon
),
);
}
}
Run the App:
In VS Code, in the bottom right status bar, click "No Device" and select an Android emulator, iOS simulator, or a connected physical device.
Press F5 or click "Run and Debug" (the green triangle icon) to start the app.
Alternatively, in your terminal, run flutter run.
You should see your simple counter app. Click the + button, and watch the number increment! Try changing the text or color in the code and hitting Ctrl+S (Cmd+S on Mac) to see Hot Reload in action.
You've built your first Flutter app! To continue your journey:
Learn more Widgets: Explore common widgets like Row, Column, ListView, Image, Button, TextField.
Navigation: Learn how to move between different screens (Navigator.push, Navigator.pop).
State Management: For more complex apps, look into Provider (simple), Riverpod, BLoC, or GetX for managing app-wide data.
Networking: How to fetch data from the internet (APIs) using packages like http.
User Input: Forms, text fields, and validating user input.
Deployment: How to prepare and publish your app to the Google Play Store and Apple App Store.
Recommended Resources:
Official Flutter Docs: Your go-to reference. flutter.dev/docs
pub.dev: Find thousands of ready-to-use packages to extend your app's functionality. pub.dev
Flutter YouTube Channel: Official tutorials and updates.
Happy coding!