Week-6-2
Week-6-2
What is Dart?
Dart Main Function
Dart Syntax
Dart Data Types
WHAT IS DART?
A few definitions of DART:
Dart is an open-source, general-purpose, object-oriented
programming language with C-style syntax developed by Google
in 2011. The purpose of Dart programming is to create frontend
user interfaces for the web and mobile apps. Inspired by other
programming languages such as Java, JavaScript, C# etc.
Dart is an object-oriented programming language developed by
Google in 2011, similar to JavaScript. Dart has the optional ability
to convert Dart code into JavaScript for a web application.
The fundamentals of Dart (a programming language) are similar
to all higher-level languages. You'll find familiarity in Dart syntax
if you're coming from JavaScript, Java, or any other C-like
language.
FLUTTER USES DART, WHY?
In the last few years, Dart has made great strides to be a nice
language specifically for writing modern UIs.
The Dart team and Flutter team get to work closely together on
feature development. This relationship allows Dart to support
Flutter, rather than Flutter rely on outside forces.
Dart supports both just in time (JIT) compiling and ahead of time
(AOT ) compiling: -- The AOT compiler changes Dart into efficient
native code. (In development mode, Flutter is compiled just-in-
time. That is why we can do hot-reload/restart so fast. In release
mode (when you go to publish your app), your code is compiled
ahead-of-time, to native code. )
void main()
{
print(“Hello World");
}
DART SYNTAX
Dart Identifiers
Identifiers are the name which is used to define variables, methods, class,
and function, etc. An Identifier is a sequence of the letters([A to Z],[a to
z]), digits([0-9]) and underscore(_), but remember that the first character
should not be a numeric.
DART PRINTING AND STRING
INTERPOLATION
The print() function is used to print output on the console,
and $expression is used for the string interpolation. Below is an
example.
void main()
{
var name = "Peter";
var roll_no = 24;
print("My name is ${name} My roll number is ${roll_no}");
}
DART DATA TYPES
The data types are the most important fundamental features of programing
language. In Dart, the data type of the variable is defined by its value. Each
variable has its data-type. The Dart is a static type of language, which
means that the variables cannot modify.
Dart supports the following built-in Data types.
Number (Integer, double)
Strings (String, var)
Boolean (bool)
Lists (var list=[1,2,3])
Maps (var person = {'name': 'Joseph', 'age':25} key-value pairing)
Runes (Unicodes -Unicode is a technique which is used to describe a unique numeric
value for each digit, letter, and symbol i.e. var smilesymbol = '\
u{1f600}'; print(laughsymbol);) //\u{1f60e}