0
0
Fluttermobile~5 mins

Flutter project structure

Choose your learning style9 modes available
Introduction

Knowing the Flutter project structure helps you find and organize your app files easily.

When you start a new Flutter app and want to understand where to put your code.
When you want to add images or fonts to your app.
When you need to change app settings like name or icon.
When you want to add packages or plugins to your project.
When you want to run or build your app on different devices.
Syntax
Flutter
my_flutter_app/
  android/
  ios/
  lib/
  test/
  pubspec.yaml
  README.md
  .gitignore

lib/ is where your Dart code lives, especially main.dart.

pubspec.yaml manages app info, dependencies, and assets.

Examples
Organize your Dart code inside lib/ with folders for screens and widgets.
Flutter
lib/
  main.dart
  screens/
  widgets/
This file lists packages your app uses, like icons.
Flutter
pubspec.yaml
  dependencies:
    flutter:
      sdk: flutter
    cupertino_icons: ^1.0.2
Android-specific files and settings are inside the android/ folder.
Flutter
android/
  app/
    src/
      main/
        AndroidManifest.xml
iOS-specific files and settings are inside the ios/ folder.
Flutter
ios/
  Runner.xcodeproj
  Runner/
    Info.plist
Sample App

This simple app shows text on the screen. It lives inside the lib/main.dart file in your Flutter project.

Flutter
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello Flutter Project Structure!'),
        ),
      ),
    );
  }
}
OutputSuccess
Important Notes

Always keep your Dart code inside the lib/ folder.

Use pubspec.yaml to add images, fonts, and packages.

Folders android/ and ios/ contain platform-specific code and settings.

Summary

The Flutter project has folders for code (lib/), platform files (android/, ios/), and tests (test/).

pubspec.yaml manages app info, dependencies, and assets.

Understanding this structure helps you build and organize your app smoothly.