Flutter Basics
Flutter Basics
Fast & Smooth: Dart compiles to native code for speedy performance, ideal for mobile apps.
Easy to Learn: Similar to familiar languages like Java or Javascript, making it approachable for
new developers.
Flutter Power: Dart is the heart of Flutter, a popular framework for building beautiful and
functional mobile apps.
One Code, Many Places: Develop for mobile, web, and even desktop with a single codebase
(primarily with Flutter).
Dart Basics
In this section, you will explore into the fundamental concepts of Dart programming. Dart is a versatile
language known for its simplicity and efficiency in developing applications for various platforms.
You'll start by understanding basic syntax and data types, essential for writing clear and concise code.
Explore how Dart handles variables, functions, and control flow statements, laying a solid foundation
for building more complex applications.
Introduction to Dart Programming Language
Dart - SDK Installation
Dart - Comments
Dart - Variables
Dart - Operators
Dart - Standard Input Output
Data Types are used for defining the type of data that a variable can store. We can store multiple types
of data in Dart as mentioned below:
Control Flow in Programming is refers to the order in which set of instructions or statements that are
executed or evaluated. It provides flexibility in Decision making and makes code more user friendly.
Dart - If-Else Statements
Dart - Switch Case Statements
Dart - Loops
Dart - Loop Control Statements
Labels in Dart
Functions are used for making our Dart Programs more organised and efficient. Here, we will check
how to build functions and learn about few inbuilt functions in Dart which can lower some of the loads
from us.
Dart - Function
Dart - Types of Functions
Dart - Anonymous Function
Dart - main() Function
Dart - Common Collection Methods
Dart - exit() function
Getter and Setter Methods in Dart
OOPS is important part of Dart Programming Language let us learn topics from encapsulation to
inheritance, polymorphism, abstract classes, and iterators, we’ll cover the essential concepts that
empower you to build modular, reusable, and scalable code.
Dart - Classes & Objects
Dart - Constructors
Dart - Super Constructor
Dart - this Keyword
Dart - static Keyword
Dart - super Keyword
Dart - Const And Final Keyword
Dart - Inheritance
Dart - Methods
Dart - Method Overloading
Dart - Getters & Setters
Dart - Abstract Classes
Dart - Builder Class
Concept of Callable Classes in Dart
Dart - Interfaces
Dart - extends Vs with Vs implements
Dart Utilities
In this section, we explore Dart utilities that enhance development efficiency. Dart offers a robust set of
utility functions and libraries that simplify common tasks like handling collections, working with dates
and times, and managing asynchronous operations. These utilities empower developers to write cleaner,
more concise code, speeding up the development process and improving code maintainability.
Dart - Date and Time
Using await async in Dart
Data Enumeration in Dart
Dart - Type System
Generators in Dart
Dart Programs
Dart programs are structured using clear syntax and support object-oriented principles, making them
versatile for both beginners and experienced developers alike. You'll learn how to write and execute
Dart code, understand variables, functions, and control flow structures essential for building functional
and efficient applications.
How to Combine Lists in Dart?
Dart - Finding Minimum and Maximum Value in a List
Dart - Splitting of String
How to Append or Concatenate Strings in Dart?
How to Find the Length of a String in Dart?
Dart - Sort a List
How to convert a lowercase string to an uppercase string?
How to convert all characters of a string to lowercase?
How to Replace a Substring of a String in Dart?
How to Check String is Empty in Dart?
Advance Concepts
In the advance concept section you will explore advanced concepts of Dart in depth. These concepts
build upon the foundational knowledge you've gained, allowing you to tackle more complex challenges
in Dart programming. From mastering asynchronous programming and working with streams to
implementing advanced design patterns like dependency injection and state management, these topics
are essential for developing scalable and efficient applications.
Exception Handling in Dart
Assert Statements in Dart
Fallthrough Condition in Dart
Concept of Isolates in Dart
Dart - Typedef
Dart - URIs
Dart - Collections
Dart - Packages
Dart - Generators
Dart - Callable Classes
Dart - Isolates
Dart - Async
Dart – String codeUnits Property
Dart - HTML DOM
Like other languages (C, C++, Java), whenever a variable is created, each variable has an associated data
type. In Dart language, there are the types of values that can be represented and manipulated in a
programming language.
In this article, we will learn about Dart Programming Language Data Types.
// Declare an integer
int num1 = 2;
// Perform addition
// (int + double results in a double)
var sum = num1 + num2;
void main() {
Output:
GeeksforGeeks
Coding is Fun
3. Boolean (bool)
It represents Boolean values true and false. The keyword bool is used to represent a Boolean literal in
dart.
Declaring Boolean in Dart
bool var_name;
Below is the implementation of Boolean in Dart:
// Dart program to demonstrate
// Boolean Data Type
void main() {
Output:
true
false
4. Lists (List)
List data type is similar to arrays in other programming languages. A list is used to represent a
collection of objects. It is an ordered group of objects.
Declaring List in Dart
There are multiple methods to declare List in Dart as mentioned below:
1. Variable Size List
// Empty growable list (preferred way)
List<int> var_name1 = [];
// Alternative: Declaring a list but not initializing (null safety requires ? if uninitialized)
List<int>? var_name2;
Output:
[Geeks, For, Geeks]
Geeks
5. Sets (Set)
A Set is an unordered collection of unique elements.
Declaring Set in Dart
// Method 1: Using curly braces
Set<int> uniqueNumbers = {1, 2, 3, 3, 4};
Output:
{USA, India}
6. Maps (Map)
The Map object is a key and value pair. Keys and values on a map may be of any type. It is a dynamic
collection.
Declaring Map in Dart
While Declaring Map there can be only two cases one where declared Map is empty and another where
declared Map contains elements in it. Both Cases are mentioned below:
1. Declaring Empty Map
// Method 1: Nullable Map declaration (can be assigned later)
Map? mapName;
7. Runes (Runes)
Dart utilizes Runes to represent Unicode characters that fall outside the standard ASCII character set.
Since Dart strings are encoded in UTF-16, certain special characters such as emojis and non-English
scripts must be expressed using runes.
Declaring Runes in Dart
String heart = '\u2665'; // Unicode for ♥
Below is the implementation of Runes in Dart:
void main() {
// Unicode for heart symbol (♥)
String heart = '\u2665';
print(smiley); // Output:
print(star); // Output: ★
print(musicNote); // Output: ♫
Output:
♥
★
♫
8. Symbols (Symbol)
A Symbol in Dart is an immutable identifier that represents variable names, method names, or metadata
at runtime. Symbols are primarily used in reflection and are helpful for dynamic programming.
Declaring Symbols in Dart
Symbol sym1 = #mySymbol;
Symbol sym2 = Symbol("anotherSymbol");
Below is the implementation of Symbols in Dart:
void main() {
// Declaring a Symbol
// using the # syntax
Symbol sym1 = #dart;
Output:
Symbol("dart")
Symbol("flutter")
Dart
Flutter
9. Null (Null)
Dart uses null to indicate the absence of a value. It has null safety, which means variables must be
either nullable (?) or initialized before they can be used.
Declaring Null in Dart
String? name; // Can be null
Below is the implementation of Null in Dart:
void main() {
// Assigning values
name = "GFG";
age = null;
// Checking for null values
// using null-aware operators
print(name ?? "Unknown"); // Output: Vinay
print(age ?? "No age provided"); // Output: No age provided
print(length);
// Output: 5
}
Output:
GFG
No age provided
3
Note: If the type of a variable is not specified, the variable’s type is dynamic. The dynamic keyword is
used as a type annotation explicitly.