Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Project Structure and Hot Reload | Flutter Basics
Flutter App Foundations

bookProject Structure and Hot Reload

Note
Definition

The Flutter project structure is the organization of files and folders that make up a standard Flutter app. This structure helps you keep your code, assets, and platform-specific files organized, making your project easier to manage and maintain.

Key Folders and Files in a Flutter Project

  • The lib folder: contains your Dart source code, including the main entry point and app logic;
  • The pubspec.yaml file: manages app metadata, dependencies, assets, and configuration;
  • The android folder: holds Android-specific code and configuration;
  • The ios folder: contains iOS-specific code and configuration;
  • The test folder: stores Dart test files for unit and widget testing.
lib/main.dart

lib/main.dart

copy
1234567891011121314151617181920
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!'), ), ), ); } }

Hot reload works by injecting updated source code into the running Dart Virtual Machine (VM). Your app's state is preserved, so you can quickly experiment with UI tweaks and see the results in real time. This makes the development process much faster and more interactive.

lib/main.dart

lib/main.dart

copy
12345678910111213141516171819202122
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { // Change the message below and use hot reload to see the update instantly. const String message = 'Initial Message'; return MaterialApp( home: Scaffold( body: Center( child: Text(message), ), ), ); } }
Note
Note

Hot reload cannot update certain types of code changes, such as modifications to main() or initialization code, changes to dependencies in pubspec.yaml, or updates to native platform code in the android or ios folders. For these changes, you must perform a full restart of your app.

question mark

Which folder in a Flutter project contains the main Dart code for your app?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 2

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

bookProject Structure and Hot Reload

Veeg om het menu te tonen

Note
Definition

The Flutter project structure is the organization of files and folders that make up a standard Flutter app. This structure helps you keep your code, assets, and platform-specific files organized, making your project easier to manage and maintain.

Key Folders and Files in a Flutter Project

  • The lib folder: contains your Dart source code, including the main entry point and app logic;
  • The pubspec.yaml file: manages app metadata, dependencies, assets, and configuration;
  • The android folder: holds Android-specific code and configuration;
  • The ios folder: contains iOS-specific code and configuration;
  • The test folder: stores Dart test files for unit and widget testing.
lib/main.dart

lib/main.dart

copy
1234567891011121314151617181920
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!'), ), ), ); } }

Hot reload works by injecting updated source code into the running Dart Virtual Machine (VM). Your app's state is preserved, so you can quickly experiment with UI tweaks and see the results in real time. This makes the development process much faster and more interactive.

lib/main.dart

lib/main.dart

copy
12345678910111213141516171819202122
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { // Change the message below and use hot reload to see the update instantly. const String message = 'Initial Message'; return MaterialApp( home: Scaffold( body: Center( child: Text(message), ), ), ); } }
Note
Note

Hot reload cannot update certain types of code changes, such as modifications to main() or initialization code, changes to dependencies in pubspec.yaml, or updates to native platform code in the android or ios folders. For these changes, you must perform a full restart of your app.

question mark

Which folder in a Flutter project contains the main Dart code for your app?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 2
some-alt