DMarlon Studio

Dart course

The language of Flutter: one codebase for Android, iOS, web and desktop.

In DMarlon Studio, Dart is the language of the Flutter targets (mobile and desktop): design the screens on the phone canvas and the studio writes the Dart.

From scratch: everything you need to write your first programs.

  1. 1Hello, worldYour first Dart program: the main() function, print() for text and numbers, single or double quotes, and the semicolon.Lesson 1
  2. 2var, final, const and typesDeclare Dart variables with their type (String, int, double, bool), with var, final and const, and check each value's type with runtimeType.Lesson 2
  3. 3Numbers and arithmeticDo arithmetic in Dart: +, -, *, division with / that gives a double, integer division ~/ and remainder %, rounding, and the += and ++ operators.Lesson 3
  4. 4Strings and interpolationWork with text in Dart: joining strings with +, interpolation with $ and ${}, characters by index, escapes, multi-line strings and the * operator.Lesson 4
  5. 5Reading inputRead what the user types in Dart with stdin.readLineSync() from dart:io and turn it into numbers with int.parse, double.parse and int.tryParse.Lesson 5
  6. 6if, else and the conditional operatorMake decisions in Dart with if, else if and else, combine conditions with &&, || and !, and pick a value in one line with the ? : operator.Lesson 6
  7. 7switch and switch expressionsChoose between many cases with switch in Dart 3: the classic statement, the new switch expression with =>, patterns such as || and >=, and when guards.Lesson 7
  8. 8for, while and do-whileRepeat code in Dart with for, while and do-while loops, and control each turn with break and continue: a times table, savings and a countdown.Lesson 8
  9. 9ListsStore several values in order with Dart lists: List<String>, indexes from 0, first and last, looping with for-in, contains and indexOf.Lesson 9
  10. 10Working with listsChange lists in Dart: add with add, addAll and insert, take out with remove, removeAt and removeLast, order with sort and copy parts with sublist.Lesson 10
  11. 11SetsUse Dart sets to store values without repeats: remove duplicates with toSet() and compare hobbies with intersection, union and difference.Lesson 11
  12. 12MapsStore key-value pairs in a Dart Map: a café menu with [], ??, remove, containsKey, entries and a count of orders.Lesson 12
  13. 13Functions and arrow syntaxWrite Dart functions with a return type, return and the => arrow syntax, use void, and store functions in variables: a temperature converter.Lesson 13
  14. 14Named and optional parametersMake flexible Dart functions with optional parameters in [ ], named parameters in { }, default values and required.Lesson 14
  15. 15Null safetyUnderstand Dart's null safety: nullable types with ?, the ??, ?., ! and ??= operators, and how an if != null check changes the type.Lesson 15
  16. 16String methodsHandle text in Dart with trim, toUpperCase, contains, indexOf, replaceAll, substring, split, join, padLeft and padRight.Lesson 16
  17. 17forEach, map, where, reduce and foldGo through and transform Dart collections with forEach, map, where, reduce and fold, and chain them to filter, convert and add up in one go.Lesson 17
  18. 18ExceptionsHandle errors in Dart with try, on, catch and finally, and raise your own with throw: a cash machine that refuses negative amounts and overdrafts.Lesson 18
  19. 19Writing and reading filesSave and read text files in Dart with the File class from dart:io: writeAsStringSync, FileMode.append, readAsStringSync and readAsLinesSync.Lesson 19
  20. 20Project: shopping cartA Dart project that brings the course together: a shopping cart with maps, functions, exceptions, null safety, fold and a switch expression for the discount.Lesson 20

For those who know the basics: the techniques used in real projects.

  1. 1Classes and initializer listsDefine Dart classes with final fields, this-shorthand constructors and initializer lists that prepare the data before the constructor body runs.Lesson 1
  2. 2Named and factory constructorsBuild Dart objects in several ways: named, redirecting and private constructors, plus factory constructors that validate input or reuse objects.Lesson 2
  3. 3Getters, setters and private membersProtect the state of your Dart classes with private members (_), computed getters and validating setters, using a bank account as the example.Lesson 3
  4. 4Inheritance and @overrideInherit Dart classes with extends, pass data to the parent with super and replace methods with @override, using a payroll example.Lesson 4
  5. 5Abstract classes and interfacesDefine contracts in Dart with abstract classes and interfaces, and see the difference between extends and implements with several payment methods.Lesson 5
  6. 6MixinsReuse behaviour in Dart with mixins: with to apply them, on to restrict them and abstract members that ask the class for data.Lesson 6
  7. 7Extension methodsAdd methods and getters to int, String or List in Dart with extensions, generic ones included, without subclassing or changing those classes.Lesson 7
  8. 8Enhanced enumsGive your Dart enums fields, a constructor and methods, and use one to model an order's life cycle with a switch the compiler checks.Lesson 8
  9. 9GenericsWrite generic classes and functions in Dart, with bounded types (extends) and type inference, using an in-memory repository and a groupBy function.Lesson 9
  10. 10Records and destructuringReturn several values without writing a class using Dart 3 records, and destructure them into variables, in loops and in swaps.Lesson 10
  11. 11Patterns and sealed classesModel a screen's states with Dart 3 sealed classes and handle them with an exhaustive switch, object patterns, when guards and if-case.Lesson 11
  12. 12Operators, == and hashCodeDefine operators on your Dart classes, compare objects by value with == and hashCode, and sort them with Comparable, using a Money type.Lesson 12
  13. 13Futures, async and awaitUnderstand Dart Futures and write readable asynchronous code with async and await, simulating server calls with Future.delayed.Lesson 13
  14. 14Future.wait and async errorsRun several requests in parallel with Future.wait in Dart and handle their errors with try/catch, timeout and onError, with output that never changes.Lesson 14
  15. 15Streams with async* and await forCreate Dart streams with async* functions and yield, consume them with await for and transform them with where and map, using a simulated download.Lesson 15
  16. 16StreamController and eventsEmit your own events in Dart with a StreamController and listen to them with listen, onError and onDone, using a shopping cart as the example.Lesson 16
  17. 17Isolates with Isolate.runMove heavy computation off Dart's main thread with Isolate.run, run several isolates in parallel and catch their errors.Lesson 17
  18. 18JSON with fromJson and toJsonRead and write JSON in Dart with jsonDecode and jsonEncode, and turn it into typed objects with fromJson and toJson, just as Flutter apps do.Lesson 18
  19. 19Iterables and generatorsProduce lazy sequences in Dart with sync*, yield and yield*: work with infinite series and compute only what is actually requested.Lesson 19
  20. 20Project: order processingCombine Dart sealed classes, generics, async and JSON in a small order processing system: the logic that sits behind a Flutter app.Lesson 20