Tsallaka zuwa abun ciki
Justice Tech School

Dart Tutorial

The language of Flutter for apps on every screen.

Start learning Dart
Getting started3 lessons
  1. 1Dart IntroductionDart is a modern language from Google, designed for fast apps on any screen.
  2. 2Dart Get StartedInstall the Dart SDK or Flutter, or try code in DartPad in the browser.
  3. 3Dart SyntaxEvery program starts at main.
Basics22 lessons
  1. 4Dart VariablesDeclare with var (type inferred) or a type such as int and String.
  2. 5Dart Data TypesTypes: int, double, String, bool, List, Set, Map and null.
  3. 6Dart StringsStrings use single or double quotes.
  4. 7Dart Null SafetyTypes are non nullable by default.
  5. 8Dart Type ConversionConvert with int.parse, double.parse, toString, toInt and toDouble.
  6. 9Dart Input and Outputprint writes a line.
  7. 10Dart CommentsUse // for one line, /* */ for several lines and /// for documentation comments that tools.
  8. 11Dart Booleansbool has two values, true and false.
  9. 12Dart Mathdart:math has sqrt, pow, min, max, Random and pi.
  10. 13More String Methodssplit, join, padLeft, startsWith, endsWith, indexOf, trim and a StringBuffer handle most t.
  11. 14Dart Date and TimeDateTime.now gives the current moment.
  12. 15The main FunctionEvery Dart program starts in main().
  13. 16var, final and constvar infers a type and can change.
  14. 17Built in Typesint, double, num, String, bool, List, Set, Map and dynamic.
  15. 18Null SafetyTypes are non-nullable by default.
  16. 19String Interpolation$name inserts a variable and ${expression} inserts any expression.
  17. 20Type Conversionint.parse, double.parse, tryParse, toString, toInt and toDouble convert values.
  18. 21dart:mathImport dart:math for sqrt, pow, min, max, pi and Random.
  19. 22OperatorsArithmetic includes ~/ for integer division.
  20. 23Cascade Notation.
  21. 24Conditional Expressionscond ? a : b and a ?? b choose between values.
  22. 25Comments and Documentation// starts a line comment and /// a documentation comment that tools show.
Operators2 lessons
  1. 26Dart OperatorsArithmetic: + - * / ~/ %.
  2. 27Assignment and Null Aware Operators+=, -=, *= and /= shorten updates.
Control flow10 lessons
  1. 28Dart If and Elseif runs code when a condition is true.
  2. 29Dart Switchswitch compares a value to cases.
  3. 30Dart Loopsfor repeats with a counter, for in visits collections, while and do while use conditions.
  4. 31if and elseConditions must be bool.
  5. 32switch Statements and ExpressionsDart 3 switch expressions return values.
  6. 33for and for-in Loopsfor counts, for in walks collections and forEach runs a function.
  7. 34while and do whilewhile checks first and do while runs at least once.
  8. 35break, continue and Labelsbreak leaves a loop and continue skips.
  9. 36Collection if and forBuild lists with if and for inside the literal.
  10. 37Pattern Matching and RecordsRecords group values and patterns destructure them.
Collections14 lessons
  1. 38Dart ListsA List is an ordered, growable collection.
  2. 39Dart Sets and MapsA Set keeps unique values.
  3. 40Collection Methodsmap, where, reduce, fold, any, every and sort transform collections.
  4. 41Sorting and Iterablessort changes a list in place with an optional comparison function.
  5. 42ListsLists are ordered and growable.
  6. 43List Methodssublist, indexOf, contains, join, reversed, take and skip are everyday tools.
  7. 44SetsSets hold unique values.
  8. 45MapsMaps hold key value pairs.
  9. 46Spread Operators.
  10. 47Sorting and Comparingsort takes a compare function.
  11. 48toList, toSet and expandConvert between collections and flatten nested ones.
  12. 49Queue and IterableQueue from dart:collection works at both ends.
  13. 50String Methodslength, substring, split, replaceAll, trim, toUpperCase, contains and padLeft.
  14. 51Regular ExpressionsRegExp tests patterns and finds matches.
Functions10 lessons
  1. 52Dart FunctionsA function has a return type, a name and parameters.
  2. 53Optional and Named ParametersPositional parameters can be optional in square brackets, and named parameters go in curly.
  3. 54Closures and Function ValuesFunctions are objects.
  4. 55FunctionsDeclare a return type, name and parameters.
  5. 56Named and Optional ParametersCurly braces make named parameters, square brackets positional optionals.
  6. 57Closures and Function TypesFunctions are objects.
  7. 58Higher Order Functionsmap, where, reduce, fold and any take functions.
  8. 59RecursionA function may call itself with a base case.
  9. 60typedef and Callbackstypedef names a function type so callbacks read clearly.
  10. 61Generators: sync* and async*sync* returns an Iterable and yield produces values lazily.
Object oriented Dart19 lessons
  1. 62Dart Classes and ObjectsA class has fields and methods.
  2. 63Dart ConstructorsNamed constructors give extra ways to create objects, and factory constructors can return .
  3. 64Getters, Setters and Privacyget and set define computed properties.
  4. 65Dart InheritanceUse extends to inherit from one class, @override to replace a method and super to reach th.
  5. 66Abstract Classes and InterfacesAn abstract class cannot be instantiated.
  6. 67MixinsA mixin shares behaviour across classes without inheritance.
  7. 68Enums and RecordsEnhanced enums have fields and methods.
  8. 69ClassesA class has fields, a constructor and methods.
  9. 70ConstructorsNamed constructors, factory constructors and initialiser lists give flexibility.
  10. 71Getters and Settersget and set make computed properties.
  11. 72Inheritanceextends creates a subclass.
  12. 73abstract Classes and Interfacesabstract classes cannot be created.
  13. 74MixinsA mixin reuses code across classes with with.
  14. 75EnumsEnhanced enums have fields and methods.
  15. 76Static Membersstatic members belong to the class.
  16. 77GenericsType parameters with bounds make reusable classes and functions.
  17. 78Extension Methodsextension adds methods to existing types.
  18. 79toString, == and hashCodeOverride toString for readable output and == with hashCode for value equality.
  19. 80Operator Overloading and Callable Classesoperator + and call() make types behave like numbers or functions.
Errors and files13 lessons
  1. 81Dart Exceptionstry, catch and finally handle errors.
  2. 82Dart Filesdart:io offers File with readAsString, writeAsString and exists.
  3. 83try, catch and finallyHandle exceptions with on and catch.
  4. 84throw and Custom Exceptionsthrow raises any object.
  5. 85Futures and async/awaitA Future is a value available later.
  6. 86StreamsA Stream delivers many values over time.
  7. 87Files with dart:ioFile reads and writes files.
  8. 88JSON with dart:convertjsonEncode and jsonDecode convert between objects and text.
  9. 89Dates and DurationsDateTime and Duration handle time.
  10. 90Null Aware Operators?., ??, ??= and ! handle nullable values.
  11. 91Practice: Word FrequencySplit, count in a map and sort.
  12. 92Practice: FizzBuzzCombine a loop and a switch expression.
  13. 93Practice: Bank AccountCombine a class, getter and exception.
Advanced DartPremium6 lessons
  1. 94Dart GenericsGenerics make classes and functions work with many types safely.
  2. 95Futures, async and awaitA Future is a value that arrives later.
  3. 96StreamsA Stream delivers a sequence of values over time.
  4. 97IsolatesDart code runs in an isolate with its own memory.
  5. 98Extension MethodsExtensions add methods to existing types without changing them.
  6. 99Patterns and Sealed ClassesDart 3 patterns destructure values in switch, if and variable declarations.
Dart in practicePremium8 lessons
  1. 100Flutter BasicsFlutter builds UIs from widgets.
  2. 101Flutter StateA StatelessWidget never changes.
  3. 102Flutter LayoutRow and Column arrange children, Expanded shares space, Padding and SizedBox add spacing, .
  4. 103HTTP and JSONThe http package makes requests and dart:convert decodes JSON with jsonDecode and encodes .
  5. 104Packages and pubspecpub.dev hosts packages.
  6. 105Testing DartThe test package runs unit tests, and flutter_test adds widget tests.
  7. 106Dart Best PracticesPrefer final and const, use null safety instead of checks, keep widgets small, run dart fo.
  8. 107Building and Publishingflutter build apk or appbundle makes an Android release, flutter build ios prepares iOS an.
More Dart basics8 lessons
  1. 108assertassert checks a condition while developing and does nothing in release builds.
  2. 109late Variableslate delays initialisation until first use and can make expensive values lazy.
  3. 110Characters and RunesStrings are UTF-16.
  4. 111Type Tests and Castsis checks a type and as casts.
  5. 112Iterable Helpersfirst, last, isEmpty, single, takeWhile and skipWhile read collections.
  6. 113const and Unmodifiable Collectionsconst lists cannot change.
  7. 114Command Line ArgumentsArguments arrive as a list of strings in main.
  8. 115Libraries and Importsimport brings in libraries.
Next steps1 lessons
  1. 116What Next?Build a small Flutter app with navigation, an API and local storage.