0% found this document useful (0 votes)
6 views3 pages

CH-4-Creating Starter Project Template

The document outlines the process of creating a starter project template in Flutter, emphasizing the importance of organizing folders and files for clarity. It provides steps for setting up a new project, structuring widgets, and creating necessary Dart files, while highlighting key points such as import statements and the entry point of the application. Additionally, it explains the purpose of various folders like assets, pages, models, utils, widgets, and services for better project management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

CH-4-Creating Starter Project Template

The document outlines the process of creating a starter project template in Flutter, emphasizing the importance of organizing folders and files for clarity. It provides steps for setting up a new project, structuring widgets, and creating necessary Dart files, while highlighting key points such as import statements and the entry point of the application. Additionally, it explains the purpose of various folders like assets, pages, models, utils, widgets, and services for better project management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Creating a Starter Project Template

1. Organizing Folders and Files


To maintain clarity and ease of use, group similar functionalities and files in dedicated folders. The
default structure of a Flutter project can be extended to include custom folders for better
organization.

Steps to Create a New Project

1. Start a New Project: Create a Flutter project and provide a project name.

Setup Folders: Organize your project with the following folder structure:

Creating the Folder Structure Using Terminal:


You can create these folders using commands. Open the terminal in your project and run:
On Windows:

mkdir assets\images
mkdir lib\pages
mkdir lib\models
mkdir lib\utils
mkdir lib\widgets
mkdir lib\services
2. Structuring Widgets
Proper widget organization is essential for maintainable and readable code.
Flutter does not create additional files for pages automatically, so you'll need
to structure widgets manually.

Steps for Widget Organization

1. Separate the Home Screen: Create a home.dart file inside the lib/pages
folder for the main screen of the app.
2. Use the main.dart File: This file serves as the entry point of the
application.
3. Choose a Widget Type:

 Use StatelessWidget if the UI does not change.


 Use StatefulWidget if the UI involves dynamic changes, like
user interactions.

3. Creating Dart Files and Widgets


Code for home.dart

4. Key Points to Remember


Import Statements: Always import the necessary packages. For Material Design, import:
import 'package:flutter/material.dart';

Entry Point: The main() function is the starting point of the app and calls runApp() to launch
the application.

Base Widget: Use MaterialApp or CupertinoApp depending on the design language you prefer.

5. Why Use These Structures?

assets/images: Keep media files like icons and images.


lib/pages: Separate screens for clarity and modularity.
lib/models: Handle data structures and objects.
lib/utils: Store utility functions like data conversions.
lib/widgets: Reuse components across multiple screens.
lib/services: Manage data fetching, APIs, or cloud services.

You might also like