Dart fundamentals for flutter

Programming Fundamentals

  1. Variables

  2. Strings

  3. Conditions

  4. Loops

  5. Functions

  6. Lists

  7. Map

  8. Classes

  9. Async and await

  10. File handling


Variables

  • Variables are containers that store value.

Declaration:

  • declaring variables with "var".
var name = "flutter";

Type inference:

  • Dart automatically determines the variables type based on their assigned values.

  • In the above code block the variable "name" is automatically inferred to be string.

Explicit Typing:

  • You can also specify variables type in dart.
String city = "Hyderabad";
int age = 23;
double pi = 3.14;
bool isRainy = true;

Mutability:

  • Variables can be mutable (changeable) or immutable (unchangeable) using "final" or "const" keyword.
final name = "dart";
const pi = 3.14;

Strings

Creating Strings:

  • You can create strings with single quote ('') or double quote ("") in Dart.
var bob = 'hello';
var candy = "hello";
  • For multiple line Strings use triple quotes (''' or """)
var triple = """
Triple quotes are used to write 
multiple lines in 
strings
"""

String interpolation:

  • Embed expressions inside string using ${}
var name = "dart";
var greeting = "hello, $name"
var length = "The length is ${name.length}"

Concatenation:

use '+' operator or simply place strings next to each other.

/

0
Subscribe to my newsletter

Read articles from Singaraju Saiteja directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Singaraju Saiteja
Singaraju Saiteja