Learn/Orientation/Your First Flutter UI

Your First Flutter UI

Build your first Flutter screen step by step

8 min~7 min read+35 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Step 1: The Basic App Shell
  2. 2. Understanding Each Widget
  3. 3. Step 2: Styling Text
  4. 4. Step 3: Layout Widgets
  5. 5. Step 4: Building a Profile Card
  6. 6. Widgets We Used
  7. 7. Turn This Demo Into A Mini Product
  8. 8. This Lesson In Simple Words
  9. 9. Your level focus
  10. 10. One practical habit
  11. 11. Deep Understanding Guide
  12. 12. Why this lesson matters
  13. 13. Study flow for better retention
  14. 14. Quick Glossary

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Your First Flutter UI

Now it is time to build something real. In this lesson, we will create a profile card step by step and learn essential widgets along the way.

Step 1: The Basic App Shell

Every Flutter app starts with this basic structure. The MaterialApp widget wraps your entire app, and the Scaffold provides a screen layout with an AppBar at the top and a body area for your content.

dart
1import 'package:flutter/material.dart';
2
3void main() {
4 runApp(MyApp()); // Start the app
5}
6
7class MyApp extends StatelessWidget {
8 @override
9 Widget build(BuildContext context) {
10 return MaterialApp( // Root widget
11 home: Scaffold( // Screen structure
12 appBar: AppBar(
13 title: Text('My First App'),
14 ),
15 body: Center( // Center the content
16 child: Text('Hello World!'),
17 ),
18 ),
19 );
20 }
21}

Understanding Each Widget

WidgetWhat It DoesAnalogy
MaterialAppWraps your app with Material Design themeThe app container
ScaffoldProvides screen structure with AppBar and bodyThe page skeleton
AppBarTop navigation bar with titleThe header
CenterCenters its child widget on screenA centering wrapper
TextDisplays text on screenA text label

Widget = Lego Block

💡 Widget = Lego Block

Think of widgets as Lego blocks. You snap them together to build your UI. Each widget handles one thing well. Text shows text, Center centers things, and Column stacks things vertically. By combining these simple widgets, you can build complex and beautiful interfaces.

Step 2: Styling Text

Flutter uses the TextStyle class to customize how text looks. You can control the font size, weight, color, spacing, and more.

dart
1// Plain text
2Text('Hello')
3
4// Styled text
5Text(
6 'Hello Flutter!',
7 style: TextStyle(
8 fontSize: 28, // Size in logical pixels
9 fontWeight: FontWeight.bold, // Bold text
10 color: Colors.blue, // Text color
11 letterSpacing: 1.5, // Space between letters
12 ),
13)
14
15// Common TextStyle properties:
16// fontSize, fontWeight, color, fontStyle (italic),
17// letterSpacing, wordSpacing, decoration (underline)

Step 3: Layout Widgets

Use Column to stack widgets vertically and Row to place them horizontally. These are the two most common layout widgets in Flutter.

dart
1// Column: Stack children vertically
2Column(
3 mainAxisAlignment: MainAxisAlignment.center,
4 children: [
5 Text('Line 1'),
6 Text('Line 2'),
7 Text('Line 3'),
8 ],
9)
10
11// Row: Place children horizontally
12Row(
13 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
14 children: [
15 Icon(Icons.star),
16 Icon(Icons.star),
17 Icon(Icons.star),
18 ],
19)
20
21// SizedBox: Add spacing between widgets
22Column(
23 children: [
24 Text('Name'),
25 SizedBox(height: 10), // 10px vertical space
26 Text('Title'),
27 ],
28)

Step 4: Building a Profile Card

Now let us combine everything we have learned into a real UI. This profile card uses Container for styling, Column for vertical layout, Row for the stats, and CircleAvatar for the profile picture.

dart
1import 'package:flutter/material.dart';
2
3void main() => runApp(MyApp());
4
5class MyApp extends StatelessWidget {
6 @override
7 Widget build(BuildContext context) {
8 return MaterialApp(
9 home: Scaffold(
10 backgroundColor: Colors.grey[200],
11 appBar: AppBar(
12 title: Text('Profile'),
13 backgroundColor: Colors.blue,
14 ),
15 body: Center(
16 child: Container(
17 padding: EdgeInsets.all(24),
18 margin: EdgeInsets.all(16),
19 decoration: BoxDecoration(
20 color: Colors.white,
21 borderRadius: BorderRadius.circular(16),
22 boxShadow: [
23 BoxShadow(
24 color: Colors.black.withOpacity(0.1),
25 blurRadius: 10,
26 offset: Offset(0, 4),
27 ),
28 ],
29 ),
30 child: Column(
31 mainAxisSize: MainAxisSize.min, // Shrink to fit content
32 children: [
33 // Profile avatar
34 CircleAvatar(
35 radius: 50,
36 backgroundColor: Colors.blue,
37 child: Text(
38 'JD',
39 style: TextStyle(
40 fontSize: 32,
41 color: Colors.white,
42 fontWeight: FontWeight.bold,
43 ),
44 ),
45 ),
46 SizedBox(height: 16),
47
48 // Name
49 Text(
50 'John Doe',
51 style: TextStyle(
52 fontSize: 24,
53 fontWeight: FontWeight.bold,
54 ),
55 ),
56 SizedBox(height: 4),
57
58 // Title
59 Text(
60 'Flutter Developer',
61 style: TextStyle(
62 fontSize: 16,
63 color: Colors.grey[600],
64 ),
65 ),
66 SizedBox(height: 16),
67
68 // Stats Row
69 Row(
70 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
71 children: [
72 _buildStat('Posts', '42'),
73 _buildStat('Followers', '1.2K'),
74 _buildStat('Following', '180'),
75 ],
76 ),
77 ],
78 ),
79 ),
80 ),
81 ),
82 );
83 }
84
85 // Helper method for stats
86 Widget _buildStat(String label, String value) {
87 return Column(
88 children: [
89 Text(
90 value,
91 style: TextStyle(
92 fontSize: 18,
93 fontWeight: FontWeight.bold,
94 ),
95 ),
96 Text(
97 label,
98 style: TextStyle(
99 fontSize: 12,
100 color: Colors.grey,
101 ),
102 ),
103 ],
104 );
105 }
106}

Widgets We Used

WidgetPurpose
ContainerA box with padding, margin, and decoration like shadow, border, and color
ColumnStacks children vertically from top to bottom
RowPlaces children side by side horizontally
CircleAvatarDisplays a circular profile image or initials
SizedBoxAdds spacing between widgets
BoxDecorationStyles a Container with color, shadow, and border radius
EdgeInsetsDefines padding and margin values

These are some of the most commonly used widgets in Flutter. You will use them in almost every app you build.

Practice Tip

💡 Practice Tip

Try modifying the profile card yourself. Change the name, try different colors, add more stats, or experiment with different MainAxisAlignment values like start, end, and spaceBetween. The best way to learn Flutter is by experimenting with the code.

Turn This Demo Into A Mini Product

To move from tutorial code to app-building skill, evolve this profile card into a tiny product feature:

  • Add a follow button with local state (Following / Follow)
  • Add a short bio and location line
  • Add responsive spacing so the card looks good on narrow screens
  • Add light and dark theme support
  • Add tap feedback on each stat tile

This is how real learning happens: start from a simple UI, then layer practical requirements step by step.

Mini Product Upgrade Tasks

  • Replace static initials with a network profile image fallback flow.
  • Extract stat tile into a reusable widget with label and value parameters.
  • Make follower count update when follow button is tapped.
  • Add error-safe handling for very long names and job titles.
  • Apply consistent spacing scale (8, 12, 16, 24) across the card.

Common UI Learning Mistake

⚠️ Common UI Learning Mistake

Do not only change colors and text. Add behavior and structure changes too. Real Flutter skill comes from handling layout, state, and edge cases together.

This Lesson In Simple Words

Build your first Flutter screen step by step. This lesson adds one more building block for creating stable and user-friendly Flutter apps.

Your level focus

Build confidence with basics first; speed comes later.

One practical habit

After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.

Deep Understanding Guide

Why this lesson matters

Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.

Study flow for better retention

  1. Read one section, run one tiny example, then explain the idea in your own words.
  2. Use a simple cycle: understand, implement, test, and explain.
  3. If you can teach it in 45 seconds without notes, you understood it.

Common Mistakes To Avoid

  • Moving forward without checking whether the current concept is truly clear.
  • Copying code exactly without experimenting with small changes.
  • Skipping edge cases and only testing happy-path behavior.
  • Assuming one pattern works for every scenario without trade-off analysis.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one tiny example from memory after finishing this lesson.
  • Write one paragraph about where this concept fits in a real app.
  • Create one failure scenario and verify your app handles it safely.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "Which widget provides basic screen structure with AppBar support?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • state: Data that can change and update what the user sees.
  • build: The method that describes UI for the current state.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Your First Flutter UI" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Moving forward without checking whether the current concept is truly clear.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

Which widget provides basic screen structure with AppBar support?

Scaffold provides the basic Material Design visual layout: AppBar at the top, body content, floating action button, drawer, etc.

How do you stack widgets vertically?

Column arranges its children vertically (top to bottom). Row arranges them horizontally (left to right).

What does SizedBox(height: 16) do?

SizedBox is commonly used as a spacer between widgets. height: 16 creates a 16 logical pixel tall gap.

Which widget centers its child on screen?

Center widget centers its child both horizontally and vertically within the available space.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue