Cloud-oriented Life

Cloud Native Technology Improves Lives

Dart Language Samples

Dart is a client-optimized language for fast apps on any platform.

This collection is not exhaustive—it’s just a brief introduction to the language for people who like to learn by example.

Read more »

Swift - The powerful programming language that is also easy to learn.

Swift is a powerful and intuitive programming language for macOS, iOS, watchOS, tvOS and beyond. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.

Tradition suggests that the first program in a new language should print the words “Hello, world!” on the screen. In Swift, this can be done in a single line:

Read more »

A basic Dart program, Important concepts, Keywords

This page shows you how to use each major Dart feature, from variables and operators to classes and libraries, with the assumption that you already know how to program in another language. For a briefer, less complete introduction to the language, see the language samples page - https://dart.dev/samples.

Read more »

Asynchrony support, Generators, Isolates

Asynchrony support

Dart libraries are full of functions that return Future - https://api.dart.dev/stable/dart-async/Future-class.html or Stream - https://api.dart.dev/stable/dart-async/Stream-class.html objects. These functions are asynchronous: they return after setting up a possibly time-consuming operation (such as I/O), without waiting for that operation to complete.

Read more »

Classes, Enums, Callable Classes, Metadata

Classes

Dart is an object-oriented language with classes and mixin-based inheritance. Every object is an instance of a class, and all classes descend from Object. Mixin-based inheritance means that although every class (except for Object) has exactly one superclass, a class body can be reused in multiple class hierarchies. Extension methods are a way to add functionality to a class without changing the class or creating a subclass.

Read more »

Control flow statements, Assert, Exception

Control flow statements

You can control the flow of your Dart code using any of the following:

  • if and else

  • for loops

  • while and do-while loops

  • break and continue

  • switch and case

  • assert

You can also affect the control flow using try-catch and throw, as explained in Exceptions - https://dart.dev/guides/language/language-tour#exceptions.

Read more »

Functions, Typedefs

Functions

Dart is a true object-oriented language, so even functions are objects and have a type, Function. This means that functions can be assigned to variables or passed as arguments to other functions. You can also call an instance of a Dart class as if it were a function. For details, see Callable classes.

Here’s an example of implementing a function:

Read more »

Generics, Libraries and visibility

Generics

If you look at the API documentation for the basic array type, List, you’ll see that the type is actually List<E>. The <…> notation marks List as a generic (or parameterized) type—a type that has formal type parameters. By convention, most type variables have single-letter names, such as E, T, S, K, and V.

Read more »
0%