Build Your First Flutter App - Complete Beginner's Guide (2025)
Welcome back to VikulWrite! 👋
In my last post, I introduced myself and my mission to help you build amazing apps. Today, I'm excited to share something practical - how to build your very first Flutter app from scratch! If you've been thinking about learning Flutter but didn't know where to start, this guide is for you.
By the end of this tutorial, you'll have built a fully functional "Welcome App with User Interaction" that will give you hands-on experience with Flutter fundamentals.
Prerequisites (What You Need)
Before we dive in, make sure you have:
- Flutter SDK installed (Download from flutter.dev)
- Android Studio or VS Code (I recommend VS Code - it's lighter)
- A code editor with Flutter extension
- Basic Dart knowledge (Don't worry, I'll explain as we go!)
- 30 minutes of your time (That's all you need!)
If you haven't installed Flutter yet, check out the official installation guide on flutter.dev. Trust me, it's worth the 10 minutes!
What We're Building Today
We're creating a simple but impressive "Welcome App" with:
- ✅ A beautiful welcome screen
- ✅ User input field (TextField)
- ✅ A button that responds to clicks
- ✅ Dynamic text that changes based on user input
- ✅ Proper app structure and best practices
Why this project? Because it covers all the fundamentals you need to understand Flutter while being simple enough to complete in one sitting!
Step 1: Create Your First Flutter Project
Open your terminal and run:
flutter create my_first_app
cd my_first_app
That's it! Flutter has generated your complete project structure. Here's what each folder does:
- lib/ - Where your app code lives (this is where we'll work)
- android/ - Android-specific configurations
- ios/ - iOS-specific configurations
- pubspec.yaml - Project dependencies and configuration
Step 2: Understanding the Project Structure
Open lib/main.dart - this is the main file where everything starts. By default, it has a lot of code. Let's simplify it and understand the basics.
The default code creates a counter app. We're going to build something more interesting!
Step 3: Build Your Welcome App - The Code
Replace everything in lib/main.dart with this code:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome App',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const WelcomeScreen(),
);
}
}
class WelcomeScreen extends StatefulWidget {
const WelcomeScreen({Key? key}) : super(key: key);
@override
State<WelcomeScreen> createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
final TextEditingController _nameController = TextEditingController();
String displayName = '';
bool isButtonPressed = false;
@override
void dispose() {
_nameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
centerTitle: true,
elevation: 0,
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Welcome Text
const Text(
'Welcome to Your First App! 🚀',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 30),
// Input Field
TextField(
controller: _nameController,
decoration: InputDecoration(
hintText: 'Enter your name',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
prefixIcon: const Icon(Icons.person),
contentPadding: const EdgeInsets.all(15),
),
),
const SizedBox(height: 20),
// Submit Button
ElevatedButton(
onPressed: () {
setState(() {
displayName = _nameController.text;
isButtonPressed = true;
});
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 15,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: const Text(
'Welcome Me!',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
),
const SizedBox(height: 40),
// Display Name if Button Pressed
if (isButtonPressed)
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.circular(15),
border: Border.all(color: Colors.blue, width: 2),
),
child: Column(
children: [
const Text(
'Hello,',
style: TextStyle(fontSize: 18, color: Colors.grey),
),
const SizedBox(height: 10),
Text(
displayName.isNotEmpty ? displayName : 'Developer',
style: const TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
const SizedBox(height: 10),
const Text(
'Welcome to Flutter! 🎉',
style: TextStyle(fontSize: 16, color: Colors.green),
),
],
),
),
],
),
),
);
}
}


Step 4: Understanding the Code - Let Me Break It Down
void main() Function:
This is where your app starts. runApp(const MyApp()) tells Flutter to run your app.
MyApp Class:
This is a StatelessWidget that sets up your app's basic configuration like title, theme, and the home screen.
WelcomeScreen Class:
This is a StatefulWidget because it needs to store data (the user's name) and update the UI when the button is pressed.
State Management:
TextEditingController- Manages the input field textdisplayName- Stores the name entered by userisButtonPressed- Tracks if button was clickedsetState()- Rebuilds the UI when values change
Key Widgets Used:
Scaffold- Provides the basic app structureAppBar- The top barColumn- Arranges widgets verticallyTextField- Input field for userElevatedButton- The clickable buttonSizedBox- Adds spacingContainer- Wrapper for styling
Step 5: Run Your App
In your terminal, run:
flutter run
That's it! Your app will launch on your device or emulator. Try entering your name and clicking the button. Magic! ✨
Step 6: Let's Make It Even Better - Customizations
Add a Clear Button
Add this button below the Welcome Me button:
if (isButtonPressed)
ElevatedButton.icon(
onPressed: () {
setState(() {
_nameController.clear();
displayName = '';
isButtonPressed = false;
});
},
icon: const Icon(Icons.refresh),
label: const Text('Clear'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
),
),
Change Colors
Want different colors? Replace Colors.blue with:
Colors.red,Colors.green,Colors.purple,Colors.orange- Or create custom:
Color(0xFF123456)
Add an Icon
Replace the welcome text with:
const Icon(Icons.code, size: 60, color: Colors.blue),
const SizedBox(height: 20),
const Text('Welcome to Your First App! 🚀', ...
Common Issues & Solutions
Issue: App won't run?
- Solution: Run
flutter pub getto get dependencies
Issue: Hot reload not working?
- Solution: Press
rin terminal to hot reload, orRfor hot restart
Issue: TextField not taking input?
- Solution: Make sure you're not inside a GestureDetector without proper focus handling
Issue: Emulator too slow?
- Solution: Use physical device or enable virtualization in BIOS
What You've Learned
By building this app, you now understand:
✅ How Flutter projects are structured
✅ StatelessWidget vs StatefulWidget
✅ How to use basic widgets (TextField, Button, Container)
✅ State management with setState()
✅ How to handle user input and interaction
✅ Basic styling and layout
✅ How to use TextEditingController
✅ App lifecycle and cleanup with dispose()
Next Steps
Now that you've built your first app, here's what to do:
- Experiment - Change colors, fonts, add more input fields
- Build - Create variations like calculator input or todo app
- Learn - Dive deeper into state management (Provider, Riverpod)
- Share - Show your friends what you built!
Key Takeaways
- Start Simple - Master basics before complex patterns
- Read Error Messages - They tell you exactly what's wrong
- Use Hot Reload - It saves so much development time
- Practice - Build small projects regularly
- Join Communities - Flutter India has amazing developers ready to help
Coming Up Next 📚
In my next post, I'll be covering:
You'll learn about the most commonly used widgets with practical examples!
Your Turn!
Now that you've built your first app:
💬 Drop a comment and let me know:
- Did you face any issues? (I can help!)
- What did you think of Flutter?
- What would you like to build next?
- Any modifications you made to the app?
Want to Level Up?
Challenges for you:
- Challenge 1 (Easy): Add a count of how many times the button was pressed
- Challenge 2 (Medium): Add validation - show error if name is empty
- Challenge 3 (Hard): Save the name using local storage so it persists after app restart
Try these and share your solutions in the comments!
Happy Coding! 🚀
Vikul Tyagi
Building Flutter apps, one widget at a time
Don't forget to:
- ⭐ Star this blog
- 📢 Share with friends learning Flutter
- 📧 Subscribe for weekly tutorials
- 💬 Comment your feedback
Very helpful
ReplyDeleteThank You
DeleteHelpful content Thanks for sharing this.
ReplyDeleteThank You
DeleteVery Helpful
ReplyDeleteThank you
DeleteAmazing Tutorial
ReplyDeleteThank You
DeleteAlways love your writing style, Vikul
ReplyDeleteThank You
DeleteAmazing tutorial u r ... It's very helpful nice
ReplyDeleteThank you
DeleteThank you for sharing this helpful content
ReplyDeleteThank you
ReplyDelete