What Is Flutter?
Flutter is an open-source software development framework created by Google. It is used to build applications for platforms such as Android, iOS, web, Windows, macOS and Linux from a shared codebase.
Flutter applications are primarily written in the Dart programming language. Developers create user interfaces by combining widgets and application logic.
Official documentation: Flutter documentation.
Table of Contents
- What Is Dart?
- Why Use Flutter?
- What Are Flutter Widgets?
- StatelessWidget
- StatefulWidget
- Scaffold
- Material Design
- Flutter Layouts
- Text and Text Styling
- Buttons
- TextFields
- Navigation
- Lists
- Images
- Forms
- Flutter and APIs
- Flutter and Firebase
- State Management
- Flutter and TypeScript
- Flutter vs React Native
- Building Android Apps
- Hot Reload
- Project Structure
- Packages
- Animations
- Responsive Interfaces
- Security Basics
- Beginner Project Ideas
- Common Beginner Mistakes
- Flutter Learning Path
- Flutter Cheat Sheet
- Frequently Asked Questions
What Is Dart?
Dart is the programming language used by Flutter. It includes familiar programming concepts such as variables, functions, classes, objects, loops, conditions and asynchronous operations.
void main() {
print("Hello Flutter");
}
Before studying Flutter in depth, learn Dart fundamentals, including collections, classes, null safety and asynchronous programming.
Why Use Flutter?
- Share much of your code across supported platforms.
- Build interfaces using reusable widgets.
- Use Hot Reload during development.
- Create custom and responsive user interfaces.
- Connect applications to APIs and databases.
- Build Android and iOS applications.
- Target web and desktop platforms when appropriate.
- Use packages to add extra functionality.
Cross-platform development can reduce duplicated work, although some features still require platform-specific configuration or code.
What Are Flutter Widgets?
Widgets describe the structure and appearance of a Flutter user interface. Text, buttons, images, rows, columns and entire screens can be built from widgets.
const Text(
"Welcome to TechLearn Hub"
)
StatelessWidget
A StatelessWidget does not manage mutable state in its own State object. It is suitable for UI that depends on values supplied to it and does not need its own changing state.
import 'package:flutter/material.dart';
class Welcome extends StatelessWidget {
const Welcome({super.key});
@override
Widget build(BuildContext context) {
return const Text("Welcome");
}
}
StatefulWidget
A StatefulWidget is appropriate when a widget's state can change while the application is running, such as a counter, selected option or interactive control.
import 'package:flutter/material.dart';
class CounterPage extends StatefulWidget {
const CounterPage({super.key});
@override
State<CounterPage> createState() => _CounterPageState();
}
class _CounterPageState extends State<CounterPage> {
int count = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Count: $count"),
ElevatedButton(
onPressed: () {
setState(() {
count++;
});
},
child: const Text("Increase"),
),
],
),
),
);
}
}
Calling setState() tells Flutter that this State object's
data has changed and the affected UI should be rebuilt.
What Is Scaffold?
Scaffold provides a standard Material Design screen structure. Depending on the application, it can contain an AppBar, body, drawer, floating action button, bottom navigation and SnackBar support.
Scaffold(
appBar: AppBar(
title: const Text("My App"),
),
body: const Center(
child: Text("Hello"),
),
)
Material Design
Flutter includes Material widgets that help developers create interfaces following Google's Material Design system.
- AppBar
- Card
- FloatingActionButton
- ElevatedButton
- TextField
- NavigationBar
Flutter also supports other interface styles and custom designs.
Flutter Layouts
Layout widgets arrange other widgets on the screen.
Row
Row arranges children horizontally.
const Row(
children: [
Icon(Icons.home),
SizedBox(width: 8),
Text("Home"),
],
)
Column
Column arranges children vertically.
const Column(
children: [
Text("Name"),
Text("Email"),
Text("Phone"),
],
)
Container
Container can provide padding, dimensions, decoration and other layout features.
Container(
padding: const EdgeInsets.all(16),
child: const Text("Hello"),
)
Expanded and Flexible
Expanded fills available space inside a Row, Column or Flex. Flexible allows a child to use available space without always requiring it to fill all of that space.
Stack
Stack positions widgets on top of one another, which is useful for overlays and layered designs.
Text and Text Styling
The Text widget displays text. TextStyle controls its appearance.
const Text(
"TechLearn Hub",
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
)
You can change font size, weight, color, letter spacing and other styling properties.
Buttons in Flutter
Buttons let users perform actions.
ElevatedButton(
onPressed: () {
debugPrint("Button pressed");
},
child: const Text("Click Me"),
)
Other commonly used options include TextButton, OutlinedButton and IconButton. A button's callback defines what happens when it is pressed.
TextFields
TextField allows users to enter text such as a name, search term or email address. A TextEditingController can be used to read or manage its content.
final nameController = TextEditingController();
TextField(
controller: nameController,
decoration: const InputDecoration(
labelText: "Enter your name",
border: OutlineInputBorder(),
),
)
// In a StatefulWidget, dispose of the controller
// when it is no longer needed:
// nameController.dispose();
Lists in Flutter
ListView is commonly used to show scrollable content.
ListView(
children: const [
ListTile(title: Text("Python")),
ListTile(title: Text("JavaScript")),
ListTile(title: Text("Flutter")),
],
)
For large or dynamically loaded collections, ListView.builder can build visible list items on demand.
ListView.builder(
itemCount: 100,
itemBuilder: (context, index) {
return ListTile(
title: Text("Item ${index + 1}"),
);
},
)
Images in Flutter
Flutter can display local asset images and images from network URLs.
Local Image
Image.asset("assets/images/logo.png")
Network Image
Image.network(
"https://example.com/image.jpg",
errorBuilder: (context, error, stackTrace) {
return const Text("Image could not be loaded");
},
)
flutter:
assets:
- assets/images/logo.png
Use a real image URL in your application and consider loading, error and caching behavior for network images.
Forms in Flutter
Forms collect information from users, such as registration details, contact messages or search terms. Form and TextFormField support validation.
final formKey = GlobalKey<FormState>();
Form(
key: formKey,
child: Column(
children: [
TextFormField(
decoration: const InputDecoration(
labelText: "Your name",
),
validator: (value) {
if (value == null || value.trim().isEmpty) {
return "Please enter your name";
}
return null;
},
),
ElevatedButton(
onPressed: () {
if (formKey.currentState!.validate()) {
// Continue with valid form data.
}
},
child: const Text("Submit"),
),
],
),
)
This example shows the validation pattern. In a real screen, create and manage the GlobalKey in an appropriate State object.
Flutter and APIs
Flutter applications can communicate with online servers through HTTP APIs. The server can return JSON data for the application to display.
The http package is a common option for sending HTTP requests.
Add it to your project using the package instructions, then import it.
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> loadData() async {
final url = Uri.parse("https://example.com/api/items");
final response = await http.get(url);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
print(data);
} else {
throw Exception("Failed to load data");
}
}
This is an illustrative example: replace the URL with a real API endpoint and add suitable loading, error handling and response validation.
Flutter and Firebase
Firebase offers cloud services that can be integrated into Flutter applications using the appropriate FlutterFire packages.
- Firebase Authentication for user sign-in.
- Cloud Firestore for cloud-hosted data.
- Realtime Database for synchronized data.
- Cloud Storage for supported file storage needs.
- Firebase Cloud Messaging for notifications.
- Firebase Analytics for usage insights.
Choose services based on your application's requirements, security rules, expected usage and budget. Follow the official setup instructions before connecting a Flutter project.
State Management
State is information that can change while an application is running, such as a selected tab, login status or shopping cart.
Small applications can often start with StatefulWidget and setState(). Larger applications may benefit from a dedicated state-management approach.
- Provider
- Riverpod
- Bloc and Cubit
- GetX
Flutter and TypeScript
Flutter application code is primarily written in Dart, not TypeScript. TypeScript is a typed language based on JavaScript and is often used in web development.
Both ecosystems can work with APIs and backend services, but their languages, tools and UI approaches differ.
Flutter vs React Native
| Feature | Flutter | React Native |
|---|---|---|
| Main language | Dart | JavaScript or TypeScript |
| Maintained by | Google and its open-source community | Meta and its open-source community |
| UI approach | Flutter widgets and rendering system | React components with native platform UI |
| Android support | Yes | Yes |
| iOS support | Yes | Yes |
| Web support | Available | Available through React Native Web and related tooling |
Both can build cross-platform applications. The right choice depends on your project, the platforms you need, your team's skills and the libraries your application requires.
Building Android Apps With Flutter
A typical Android development workflow includes:
- Install Flutter and configure its development tools.
- Set up the Android SDK and a suitable testing device or emulator.
- Create a Flutter project.
- Design the interface with widgets.
- Add application logic.
- Connect APIs or databases when needed.
- Test the application on supported devices.
- Build and test a release version.
- Prepare store listing details and publishing requirements.
flutter create my_app
cd my_app
flutter run
These commands are intended for a computer or supported development environment with Flutter installed. A phone browser or basic text editor alone does not provide the full Flutter build toolchain.
Hot Reload
Hot Reload lets developers apply many code changes to a running Flutter application without restarting the entire application. This makes it easier to experiment with layouts and UI behavior.
Some changes require a full restart, and Hot Reload does not replace testing the application's final behavior.
Flutter Project Structure
A typical Flutter project may contain files and folders such as:
my_app/
├── android/
├── ios/
├── lib/
│ └── main.dart
├── test/
├── web/
├── pubspec.yaml
└── README.md
lib/commonly contains Dart application source code.main.dartoften contains the application's entry point.pubspec.yamldefines project metadata, dependencies and assets.test/can contain automated tests.- Platform folders contain platform-specific project files when generated.
The exact folders depend on the platforms and options selected when the project is created.
Packages in Flutter
Packages extend an application with functionality that would otherwise need to be written from scratch.
- HTTP networking
- Local storage
- Firebase integration
- Maps and location features
- Charts and visualizations
- Authentication
- Animations
Dependencies are usually declared in pubspec.yaml and
resolved with Flutter's package tools. Check package documentation,
maintenance status, permissions and compatibility before adding a package.
Animations in Flutter
Flutter supports animations for creating interactive user interfaces. Implicit animation widgets are useful for simple transitions, while AnimationController and related classes support more controlled animations.
- Button feedback
- Page transitions
- Loading indicators
- Animated cards
- Menus and overlays
- Interactive interface elements
Keep animations purposeful and test them on devices with different performance levels.
Responsive Flutter Interfaces
A well-designed application should adapt to different screen sizes and orientations.
Useful Flutter tools include:
- Expanded and Flexible
- LayoutBuilder
- MediaQuery
- Wrap
- Flexible and scrollable layouts
- Constraints and adaptive navigation
Avoid relying on fixed dimensions for every element. Test layouts on small phones, larger phones and tablets where relevant.
Flutter for Web and Desktop
Flutter is not limited to mobile applications. It can also target web, Windows, macOS and Linux, depending on the development environment and project requirements.
Flutter is not automatically the best choice for every website. Consider accessibility, search engine visibility, loading performance and the nature of the user experience before choosing it for a web project.
Flutter Security Basics
- Use HTTPS for secure network communication.
- Validate important data on the server.
- Protect authentication credentials and user data.
- Keep packages and development tools updated.
- Apply appropriate authentication and authorization checks.
- Configure backend access rules carefully.
- Avoid placing private server secrets in client-side application code.
Beginner Flutter Project Ideas
Practice what you learn by building small projects such as:
- Calculator App
- To-Do List
- Notes App
- Weather App using an API
- News App
- Quiz App
- Expense Tracker
- Recipe App
- Football Scores App
- Simple Chat App
Start with a small project that stores information locally. Later, add API communication, accounts or cloud storage when you understand the basics.
Common Flutter Beginner Mistakes
- Trying to learn every feature at once.
- Ignoring Dart fundamentals.
- Starting with an overly complex project.
- Copying code without understanding it.
- Ignoring error messages.
- Adding unnecessary packages.
- Failing to test different screen sizes.
- Putting too much logic into one widget or file.
- Forgetting to handle loading, empty and error states.
- Assuming client-side checks are enough to secure a backend.
Flutter Learning Path
Step 1: Learn Programming Basics
Understand variables, conditions, loops, functions and basic logic.
Step 2: Learn Dart
Study syntax, collections, classes, null safety and asynchronous programming.
Step 3: Learn Flutter Widgets
Practice Text, Container, Row, Column, Stack, ListView and buttons.
Step 4: Learn State
Understand StatefulWidget, setState and how Flutter rebuilds the UI.
Step 5: Learn Navigation
Create multiple screens and move between them.
Step 6: Learn Forms and Validation
Collect user input and display helpful validation messages.
Step 7: Learn APIs
Send requests to online services and process JSON responses.
Step 8: Learn Data Storage
Understand local storage and cloud database options.
Step 9: Build Projects
Build, test and improve complete applications gradually.
Step 10: Learn Advanced Flutter
Study architecture, state management, testing, performance and deployment.
Flutter Cheat Sheet
| Concept | Purpose |
|---|---|
| Widget | Describes part of the UI |
| StatelessWidget | Widget without its own mutable State object |
| StatefulWidget | Widget paired with a State object |
| Scaffold | Basic Material screen structure |
| Row | Horizontal layout |
| Column | Vertical layout |
| Container | Layout, spacing and decoration |
| ListView | Scrollable list |
| Navigator | Screen navigation |
| TextField | User text input |
| Future | Represents an asynchronous result |
| FutureBuilder | Builds UI based on a Future's state |
| setState() | Notifies Flutter that local State changed |
| pubspec.yaml | Project metadata, dependencies and assets |
Frequently Asked Questions
Is Flutter free?
Yes. Flutter is an open-source framework.
Do I need to learn Dart before Flutter?
You can start learning Flutter while learning Dart, but basic Dart knowledge makes Flutter much easier to understand.
Can Flutter build Android apps?
Yes. Flutter supports Android application development.
Can Flutter build iPhone apps?
Yes. Flutter supports iOS application development.
Can Flutter build web applications?
Yes. Flutter supports web development, though suitability depends on the website's purpose and performance requirements.
Can Flutter connect to an API?
Yes. Flutter applications can communicate with APIs using HTTP clients.
Can Flutter use Firebase?
Yes. Firebase services can be integrated with Flutter.
Is Flutter good for beginners?
Yes, if you learn it step by step, practice Dart fundamentals and build small projects.
What language does Flutter use?
Flutter application code is primarily written in Dart.
Can I build Flutter apps using only a phone?
The full Flutter development toolchain is normally used on a computer or compatible cloud development environment. A phone can be used to read documentation and edit code, but compiling and testing an app may require additional tools or a remote environment.
Conclusion
Flutter is a cross-platform development framework that uses Dart and a widget-based approach to build user interfaces.
Begin with Dart fundamentals, practice common widgets, learn state and navigation, and build small applications. Then progress to APIs, databases, Firebase, testing, security and deployment.