Marks Dart and Flutter Blog RSS

assertions, Dart, Google 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...

Read more

Dart, Google Flutter, maps -

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

Read more

Google, Google Flutter, Object Orientated -

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...

Read more

Dart, Google, Google Flutter -

Introduction Dart Combines Lists and Arrays In Dart, a List is an ordered Collection (sometimes called a sequence). Unlike other languages, an Array and a List have been combined together and are the same thing. A list is a number of items (objects) in an unordered structure. Additional items can be added to the list. Items can be updated or removed from the list if required. Lists may contain duplicate elements. Iterators You can use an iterator to go through the list items one by one programatically. As a developer, you will use iterators all the time. Example Note how the List in the example below (containing items...

Read more

Dart, Google, Google Flutter -

The mainstream Dart web development route is now writing code with Dart but compiling and running as JavaScript using webdev, which works with the build_runner utility.   Installing You will have to install the webdev package using the pub dependency manager: pub global activate webdev   This installs webdev and makes sure it is available on the command line.   Commands webdev serveRuns a development server that continuously builds a web app. webdev buildBuilds a deployable version of a web app. build_runner testRuns tests.   JavaScript Compilers When you invoke webdev, it invokes the dart2js and dartdevc JavaScript compilers in combination...

Read more