Google Flutter RSS
Asynchronous Processing in Dart and Flutter - Part Two - Futures and Error Handling
What is a Future? Futures are used to store the results of asynchronous processes. As mentioned in Part One, asynchronous operations can result in Success (often with data) and Failure (often with error data). A Future will store the data from the Success. Lets Run Some Code Go to your web-browser and navigate here: https://dartpad.dartlang.org. Paste the following code into the code area on the left-side: import 'dart:async'; String createLongString(int count){ print('start count up'); StringBuffer sb = new StringBuffer(); for (int i = 0; i < count; i++) { sb.write(" ${i}"); } print('finish count up'); return sb.toString(); } Future createFutureCounter(int...
Asynchronous Processing in Dart and Flutter - Part One - Overview
What is Asynchronicity? It is the ability to do multiple things at the same time. UI Thread A thread is a thread of execution in a program. It is some programming that does something. When you have a user interface, it has a single thread that accepts user input from the user (in the form of events) and updates the user interface (rendering). This is known as the UI thread. Synchronous Operations A synchronous operation blocks a process till the operation completes. If you add a synchronous operation to a UI thread then it stops the UI from repainting, responding...
Assertions in Dart and Flutter
Why Have Error & Exception Handling? Most software systems are complicated and written by a team of people. Complexity arises from multiple sources: The business domain. The act of writing software. From multiple people working together, each one having different viewpoints. etc The complexity can result in misunderstandings, errors & exceptions. This is not the end of the world if the code has good error handling. If you don't handle your errors & exceptions, your software may act unpredictably, and users may suffer a catastrophic error without knowing it or being able to detect when it...
Maps in Dart and Flutter
Introduction An object that maps keys to values. Both keys and values in a map may be of any type. A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime. Example void main() { Map<String, String> stateNamesByStateCode = {"AL": "Alamaba", "AK": "Alaska", "AR": "Arkansas", "AZ": "Arizona" }; stateNamesByStateCode["GA"] = "Georgia"; for (String key in stateNamesByStateCode.keys){ print(stateNamesByStateCode[key]); } print("\nGet just one: ${stateNamesByStateCode["AK"]}"); } Example Output Alamaba Alaska Arkansas Arizona Georgia Just one: Alaska
Object-Orientated Features in Google Dart for Java / .NET Developers
Object-Orientated Language Features Modules Unlike Java and C#, Dart allows you to declare multiple objects within a single Dart file. This has made our example code a single cut-n-paste! Private Classes, Variables & Methods Unlike Java, Dart doesn't have the keywords public, protected, and private to specify the visibilities of fields or properties. If a class name, instance variable or method starts with an underscore, it's private and cannot be accessed outside the Dart file in which it is declared. You should replace: class ContactInfo { private String name; private String phone; } with class ContactInfo { String _name; String...