Flutter Setup and First App

Getting Flutter running on your machine is straightforward. This chapter walks you through installation and creating your first project.

Install Flutter

Windows / macOS / Linux:

Bash
# Download Flutter SDK from flutter.dev or use git:
git clone https://github.com/flutter/flutter.git -b stable
export PATH="$PATH:$(pwd)/flutter/bin"

# Verify installation
flutter doctor

flutter doctor reports what's missing — follow its suggestions until you see checkmarks.

Android Studio (recommended for mobile):

  1. Install Android Studio
  2. Open it → Preferences → Plugins → install "Flutter" and "Dart"
  3. Restart → "Create New Flutter Project"

VS Code (lightweight alternative):

  1. Install the "Flutter" extension (includes Dart)
  2. Ctrl+Shift+P → "Flutter: New Project"

Create a Project

Bash
flutter create hello_nepal
cd hello_nepal

This generates:

Code
hello_nepal/
├── lib/
│   └── main.dart          # Your app starts here
├── test/                   # Widget tests
├── android/                # Android-specific code
├── ios/                    # iOS-specific code
├── web/                    # Web build
└── pubspec.yaml            # Dependencies (like package.json)

Run the App

Bash
flutter run               # on connected device/emulator
flutter run -d chrome     # on Chrome (web)
flutter run -d macos      # on macOS desktop

The pubspec.yaml

YAML
name: hello_nepal
description: My first Flutter app

environment:
  sdk: '>=3.0.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  http: ^1.0.0            # Add packages here

dev_dependencies:
  flutter_test:
    sdk: flutter

Run flutter pub get after adding dependencies.

Hot Reload

  1. Start the app with flutter run
  2. Change text in main.dart
  3. Save — the app updates instantly without losing state

This is Flutter's killer feature for rapid development.

Common Commands

Bash
flutter doctor            # Check setup
flutter create my_app     # New project
flutter run               # Run on device
flutter build apk         # Build Android APK
flutter build ios         # Build iOS
flutter test              # Run tests
flutter pub get           # Install dependencies
flutter clean             # Clear build cache

Next: widgets.