The Dart programming language is to build mobile, desktop, server, and web applications on cross platforms.
It's a client-optimized, object-oriented, class-based, garbage-collected programming language with C-style syntax.
The Flutter framework powered by the Dart platform is used for developing mobile apps.
Main advantages are Dart VM and Dart AOT
Dart also supports command-line applications.
Dart provides resources via packages (e.g. dart.io), that are used in most command-line applications, including the standard input, output, error, streams, command-line arguments, files and directories, and more.
Dart also supports building HTTP clients & servers applications.
In Dart, the dart:io library contains the classes and functions to write HTTP clients and server applications.
In addition, the http_server package contains some higher-level classes that make it easier to write clients and servers.
Dart supports the web as one of its core platforms.
Dart-to-JavaScript compilers are available both for development and for production.
In addition to compilers, the Dart web platform provides.
To build a robust web application, consider using Dart web with a higher-level web application framework like AngularDart.
Note: Many apps that support both web and mobile are built using Flutter and Flutter web support.
// Declare a function.
displayName(String name) {
// Print to console.
print('My name is $name');
}
// This is where the app starts executing.
main() {
// Declare and initialize a variable.
var fullName = "Rock Star";
// Call a function.
displayName(fullName);
}
Here’s what this program uses that applies to all (or almost all) Dart apps.
Single-line comment: A single-line comment // ignored by the Dart compiler.
// Declare a function.
Function:
A function declaration named as displayName, and String static type defined as function parameter.
displayName(String name) {}
print() function: A handy way to display output. The top-level print() method takes a single argument (any Object) and displays that object’s string value (as returned by toString()) in the console.
print('My name is $name');
String interpolation: Including a variable $name using String interpolation inside of a string literal.
'My name is $name'
main() function: A top-level function where app execution starts.
main() {}
var fullName = "Rock Star";