TechLearn Hub

Learn Technology in Simple English

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.

Simple definition: Flutter helps developers build applications for multiple platforms using a shared development framework and codebase.

Official documentation: Flutter documentation.

Table of Contents

  1. What Is Dart?
  2. Why Use Flutter?
  3. What Are Flutter Widgets?
  4. StatelessWidget
  5. StatefulWidget
  6. Scaffold
  7. Material Design
  8. Flutter Layouts
  9. Text and Text Styling
  10. Buttons
  11. TextFields
  12. Navigation
  13. Lists
  14. Images
  15. Forms
  16. Flutter and APIs
  17. Flutter and Firebase
  18. State Management
  19. Flutter and TypeScript
  20. Flutter vs React Native
  21. Building Android Apps
  22. Hot Reload
  23. Project Structure
  24. Packages
  25. Animations
  26. Responsive Interfaces
  27. Security Basics
  28. Beginner Project Ideas
  29. Common Beginner Mistakes
  30. Flutter Learning Path
  31. Flutter Cheat Sheet
  32. 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?

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"
)
Think of widgets as building blocks. Combining smaller widgets lets you create a complete application interface.

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.

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();
If you create a TextEditingController in a StatefulWidget, dispose of it in the State object's dispose() method. Avoid creating a controller repeatedly inside build().

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");
  },
)
Declare local assets in pubspec.yaml. For example:
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.

APIs are useful for news apps, weather apps, football-score apps, shopping apps and social platforms.

Flutter and Firebase

Firebase offers cloud services that can be integrated into Flutter applications using the appropriate FlutterFire packages.

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.

Beginners should first understand how state works in Flutter before learning additional state-management libraries.

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

FeatureFlutterReact Native
Main languageDartJavaScript or TypeScript
Maintained byGoogle and its open-source communityMeta and its open-source community
UI approachFlutter widgets and rendering systemReact components with native platform UI
Android supportYesYes
iOS supportYesYes
Web supportAvailableAvailable 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:

  1. Install Flutter and configure its development tools.
  2. Set up the Android SDK and a suitable testing device or emulator.
  3. Create a Flutter project.
  4. Design the interface with widgets.
  5. Add application logic.
  6. Connect APIs or databases when needed.
  7. Test the application on supported devices.
  8. Build and test a release version.
  9. 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

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.

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.

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:

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

Mobile application code can potentially be inspected or reverse engineered. Do not treat an API key or secret as safe simply because it is included inside an app. Keep sensitive server credentials on a protected backend.

Beginner Flutter Project Ideas

Practice what you learn by building small projects such as:

  1. Calculator App
  2. To-Do List
  3. Notes App
  4. Weather App using an API
  5. News App
  6. Quiz App
  7. Expense Tracker
  8. Recipe App
  9. Football Scores App
  10. 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

Build small projects and understand each feature before moving on to more complicated applications.

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

ConceptPurpose
WidgetDescribes part of the UI
StatelessWidgetWidget without its own mutable State object
StatefulWidgetWidget paired with a State object
ScaffoldBasic Material screen structure
RowHorizontal layout
ColumnVertical layout
ContainerLayout, spacing and decoration
ListViewScrollable list
NavigatorScreen navigation
TextFieldUser text input
FutureRepresents an asynchronous result
FutureBuilderBuilds UI based on a Future's state
setState()Notifies Flutter that local State changed
pubspec.yamlProject 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.

Next step: Create a small Flutter application and practice building a screen, handling a button press and moving between two pages.

Official Flutter Learning Resources