Building Your First Flutter App Step-by-Step
Building Your First Flutter App Step-by-Step
Flutter is a popular open-source UI toolkit by Google for building natively compiled apps for mobile, web, and desktop from a single codebase. Here’s a simple step-by-step guide to help you build your first Flutter app.
Step 1: Set Up Your Development Environment
Install Flutter SDK: Download Flutter from flutter.dev and follow the installation instructions for your OS (Windows, macOS, Linux).
Install an IDE: Use Visual Studio Code or Android Studio with Flutter and Dart plugins installed.
Set up a device or emulator: You can use a physical device connected via USB or launch an Android/iOS emulator.
Step 2: Create a New Flutter Project
Open your terminal or IDE and run:
bash
Copy
Edit
flutter create my_first_app
Navigate to the project folder:
bash
Copy
Edit
cd my_first_app
Open this project in your IDE.
Step 3: Understand the Default Flutter App
Flutter creates a simple counter app by default. It uses main.dart file located in lib/.
Open lib/main.dart — this file contains the main app code.
Step 4: Run Your App
Run the app using:
bash
Copy
Edit
flutter run
or press the Run button in your IDE. Your app should launch in the emulator or connected device, showing a button that increments a counter.
Step 5: Modify the App
Let’s make a simple change — change the title and button text.
Open lib/main.dart, and find the MyHomePage widget. Change:
dart
Copy
Edit
title: 'Flutter Demo Home Page',
to
dart
Copy
Edit
title: 'My First Flutter App',
And change the button’s tooltip and text:
dart
Copy
Edit
tooltip: 'Increment',
to
dart
Copy
Edit
tooltip: 'Tap to increase',
and
dart
Copy
Edit
child: Text('You have pushed the button this many times:'),
to
dart
Copy
Edit
child: Text('Number of taps:'),
Save and hot reload your app (r in terminal or the IDE hot reload button) to see changes instantly.
Step 6: Add a New Widget
Try adding a simple text widget below the counter:
dart
Copy
Edit
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Number of taps:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
Text(
'Welcome to Flutter!',
style: TextStyle(fontSize: 20, color: Colors.blue),
),
],
),
Step 7: Build & Test
Keep experimenting by adding widgets, changing styles, and using Flutter’s hot reload to see changes immediately. Use documentation and Flutter widget catalog to explore more UI components.
Summary
Set up Flutter environment.
Create a new project.
Run the default app.
Modify text and UI elements.
Add new widgets.
Use hot reload to see instant changes.
Flutter’s combination of fast development and beautiful UI makes it easy and fun to build apps quickly.
Learn Flutter Training in Hyderabad
Read More
Understanding Flutter Widgets: The Basics
Setting Up Flutter on Windows/Mac/Linux
What is Flutter? An Introduction for Beginners
Visit Our IHUB Talent Training Institute in Hyderabad
Comments
Post a Comment