Amit Acharya
Runtime Terror Blogs ( •̀ᴗ•́ )و ̑̑


Runtime Terror Blogs ( •̀ᴗ•́ )و ̑̑

Variables in Dart

Variables in Dart

Primitive/Basic Variables in dart (int, String, double)

Amit Acharya's photo
Amit Acharya
·Jul 7, 2022·

1 min read

Table of contents

  • Simple Variable
  • String Variable
  • Integer variable
  • Float/Double variable
  • A simple program that uses variables

Here’s an example of creating a variable and initializing it:

Simple Variable

var name = 'Foo';

Variables store references. The variable called name contains a reference to a String object with a value of “Bob”.

Explicitly want to set the type? No problem

String Variable

String name = 'Foo';

Want to declare integers?

Integer variable

int count = 4;

Want to declare Floating point numbers?

Float/Double variable

double f = 1.0;

double is a language keyword

A simple program that uses variables

void main() { 
   int num=10; 
   double x = 10.0;
   String y = 'Hello World!';

That's all!

Next we will look into the dart language keywords set and explore a few keywords that change the way variables behave.

See Const keyword in dart

Share this