Dart is an open-source, class-based, optionally-typed programming language for building web applications--on both the client and server--created by Google. Dart’s design goals are:
Dart targets a wide range of development scenarios, from a one-person project without much structure to a large-scale project needing formal types in the code to state programmer intent.
To support this wide range of projects, Dart provides the following features and tools:
Version | Release Date |
---|---|
1.22.1 | 2017-02-22 |
1.22.0 | 2017-02-14 |
1.21.1 | 2016-01-13 |
1.21.0 | 2016-12-07 |
1.20.1 | 2016-10-13 |
1.20.0 | 2016-10-11 |
1.19.1 | 2016-09-07 |
1.19.0 | 2016-08-26 |
1.18.1 | 2016-08-02 |
1.18.0 | 2016-07-27 |
1.17.1 | 2016-06-10 |
1.17.0 | 2016-06-06 |
1.16.1 | 2016-05-23 |
1.16.0 | 2016-04-26 |
1.15.0 | 2016-03-09 |
1.14.2 | 2016-02-09 |
1.14.1 | 2016-02-03 |
1.14.0 | 2016-01-28 |
1.13.2 | 2016-01-05 |
1.13.1 | 2015-12-17 |
1.13.0 | 2015-11-18 |
1.12.2 | 2015-10-21 |
1.12.1 | 2015-09-08 |
1.12.0 | 2015-08-31 |
1.11.3 | 2015-08-03 |
1.11.1 | 2015-07-02 |
1.11.0 | 2015-06-24 |
1.10.1 | 2015-05-11 |
1.10.0 | 2015-04-24 |
1.9.3 | 2015-04-13 |
1.9.1 | 2015-03-25 |
1.8.5 | 2015-01-13 |
1.8.3 | 2014-12-01 |
1.8.0 | 2014-11-27 |
1.7.2 | 2014-10-14 |
1.6.0 | 2014-08-27 |
1.5.8 | 2014-07-29 |
1.5.3 | 2014-07-03 |
1.5.2 | 2014-07-02 |
1.5.1 | 2014-06-24 |
1.4.3 | 2014-06-16 |
1.4.2 | 2014-05-27 |
1.4.0 | 2014-05-20 |
1.3.6 | 2014-04-30 |
1.3.3 | 2014-04-16 |
1.3.0 | 2014-04-08 |
1.2.0 | 2014-02-25 |
1.1.3 | 2014-02-06 |
1.1.1 | 2014-01-15 |
1.0.0.10_r30798 | 2013-12-02 |
1.0.0.3_r30188 | 2013-11-12 |
0.8.10.10_r30107 | 2013-11-08 |
0.8.10.6_r30036 | 2013-11-07 |
0.8.10.3_r29803 | 2013-11-04 |
void main() {
var cat = new Cat();
print("Is cat hungry? ${cat.isHungry}"); // Is cat hungry? true
print("Is cat cuddly? ${cat.isCuddly}"); // Is cat cuddly? false
print("Feed cat.");
cat.isHungry = false;
print("Is cat hungry? ${cat.isHungry}"); // Is cat hungry? false
print("Is cat cuddly? ${cat.isCuddly}"); // Is cat cuddly? true
}
class Cat {
bool _isHungry = true;
bool get isCuddly => !_isHungry;
bool get isHungry => _isHungry;
bool set isHungry(bool hungry) => this._isHungry = hungry;
}
Dart class getters and setters allow APIs to encapsulate object state changes.
See dartpad example here: https://dartpad.dartlang.org/c25af60ca18a192b84af6990f3313233
Create a new file named hello_world.dart
with the following content:
void main() {
print('Hello, World!');
}
In the terminal, navigate to the directory containing the file hello_world.dart
and type the following:
dart hello_world.dart
Hit enter to display Hello, World!
in the terminal window.
<img id="cats"></img>
import 'dart:html';
/// Stores the image in [blob] in the [ImageElement] of the given [selector].
void setImage(selector, blob) {
FileReader reader = new FileReader();
reader.onLoad.listen((fe) {
ImageElement image = document.querySelector(selector);
image.src = reader.result;
});
reader.readAsDataUrl(blob);
}
main() async {
var url = "https://upload.wikimedia.org/wikipedia/commons/2/28/Tortoiseshell_she-cat.JPG";
// Initiates a request and asynchronously waits for the result.
var request = await HttpRequest.request(url, responseType: 'blob');
var blob = request.response;
setImage("#cats", blob);
}
see Example on https://dartpad.dartlang.org/a0e092983f63a40b0b716989cac6969a
The Dart SDK includes everything you need to write and run Dart code: VM, libraries, analyzer, package manager, doc generator, formatter, debugger, and more. If you are doing web development, you will also need Dartium.
You can also manually install any version of the SDK.