MOCKSTACKS
EN
Questions And Answers

More Tutorials









Dart Manual Install


You can also manually install any version of the SDK.

Hello, World!


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.

Http Request


Html



<img id="cats"></img>

Dart



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);
}

Example


Getters and Setters



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;
}



Conclusion

In this page (written and validated by ) you learned about Dart Manual Install . What's Next? If you are interested in completing Dart tutorial, your next topic will be learning about: Dart Asynchronous Programming.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.