Learn Just Enough Dart For Flutter: Part 1

A beginner's guide to learning dart and flutter

Manthan Gupta
TheLeanProgrammer
3 min readApr 21, 2020

--

What is Dart?

Dart is a client-optimized programming language for apps on multiple platforms. It is developed by Google and is used to build mobile, desktop, server, and web applications.

Dart is an object-oriented, class-based, garbage-collected language with C-style syntax. Dart can compile to either native code or JavaScript. It supports interfaces, mixins, abstract classes, reified generics, and type inference.

So, if you prefer coding in C language or Java or know these languages then you will find it easy to pick up Dart. For the rest who have no idea about C or Java don’t worry. This 4 part blog will help you learn it.

Let’s start this!

The Famous Hello World

What can be a better way than starting with a ‘Hello World’ program? Nothing. The entry point of any dart program is the main like Java/C# etc. Also, don’t forget to add “;” at the end of every syntax line.

Declaring Variables and their Types

Variables are used to stored information so that we can reference it in the future or manipulate it as per our needs. To declare a variable in Dart we use the keyword var. Dart is a type of inferred language, the compiler automatically infers the data type of the variable by the value assigned to the variable. All the uninitialized variables give output Null.

There are some predefined variable data types in Dart that you can use too.

  1. int
  2. double
  3. String
  4. bool
  5. List
  6. Map

List and Map are used to represent a collection of objects.

Lists

A list is an ordered group of objects. Think of it as an array in Java/C++ or any other language if you are familiar with it. It is used to store multiple values in a single variable. If you are still not clear then look at the code below.

There are properties of lists that make us able to manipulate the list. Do read the comments carefully!

Maps

A map is used to represent a set of values as a key-value pair. The key-value pair need not be of the same data type. The key in the map should be unique while the value can be redundant.

Properties of Maps to manipulate with it

final & const

If you want the value of a variable to remain the same throughout the program then final and const are the keywords. Though their job is the same there is a small difference. Const keyword is a compile-time constant which means that the const variable should have a value associated with it in compile time. Whereas final variables need not have a value associated with them while compile-time. It can accept user input and store it.

Operators

An operator is a special symbol that is used to carry out some specific operation on its operand.

In this blog, I will only tackle Relational and Logical Operators only.

Relational Operators

Relational Operators are used for evaluating a comparison between operands.

Consider 2 variables A=15 and B=23

Logical Operators

Logical Operators are used to combining 2 or more conditions together.

Let’s consider 2 variables again A=15 and B=23.

That’s all for this part 1. You can find the link to the next part here. I hope you all liked this part! If you did so then smash that clap button. Also, don't forget to leave constructive comments if you think there is room for improvement.

You can follow me on LinkedIn, Github, and Twitter.

Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter tinyletter.com/TheLeanProgrammer

--

--