Shoot your shot with Dart

Victor Torres
4 min readJun 8, 2021

A programming language similar to Java, C++ and C#. Some insight to Dart.

What is Dart ??

Dart is a client-optimized language for fast apps on any platform. Primarily known as the programming language for Flutter, Google’s UI toolkit for building compiled mobile, web apps from a single codebase. It’s optimized for building user-interfaces and was developed by Google. Dart can compile to native code and JavaScript.

Its Key features have to be

Optimized for UI: Allowing you to develop with a programming language specialized around the needs of user interface creation

Productive development : You can make changes iteratively: use hot reload to see the result instantly in your running app

Fast on all platforms : Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web

The Hello

The basic greeting to the world!

A few things that stand out right away:

  • Dart needs a main() function as a starting point
  • Dart doesn’t require a class
  • Dart uses two-character indentation by convention

Two character indentation makes the code more compact. This is really helpful when you start creating a Flutter application since Flutter apps are based on a tree of nested widgets.

Darts Compact

Since flutter applications are based on a tree of nested widgets it would be ideal to reduce code size. For that reasons Dart has many features meant for that sole purpose. :

  • You can simply refer to instance variables in a bodiless constructor to automatically assign values to them
  • Strings have template-like features, allowing you to directly use variables or even expressions
  • When creating objects, you don’t need to use a special keyword, but you always have the option for those who are used to habit
  • Dart supports both top-level functions and class methods.

Objects

Everything that can be assigned to a variable, is an object. Numbers, functions, and even null are objects. Objects are based on a class, and all objects inherit from a base object with the unsurprising name of Object.

Private and public

All identifiers are public by default. Dart doesn’t have keywords for public, private, or protected.

A library within Dart is everything that is in a single file. So library privacy means that the identifier is visible only inside the file that the identifier is defined in. To mark a Dart identifier private to its library, start its name with an underscore.

Expressions and statements

Dart has both expressions that result in a value and statements that don’t. This doesn’t differ from many of the other languages. Some of the usual suspects that are available in Dart too:

  • while loops and for loops
  • if else statements
  • The switch statement
  • Exceptions

Type Inference

Dart is strongly typed. But did you notice that Dart uses type inference? You do not need to specify the type of variable. Instead, Dart inferred the type for us at compile time. This is in line with other modern languages like Kotlin. Its removes a burden in a sense.

Take Away

Dart is a modern, easy to learn language. It is the language for flutter and has a growing strong community. There are multiple docs, samples and tutorials as well as resources available on their site.

Dart can be easily accessed and downloaded. Although it ideally is used for native platforms it can and is used for Web platforms as well. It is the perfect partner for flutter and it definitely will allow you to shoot even better shots.

--

--

Victor Torres

Full Stack Software Engineer || Entrepreneur at heart , engineer by training. Comedian in the eyes off my peers.