Flutter for Beginners
上QQ阅读APP看书,第一时间看更新

Control flows and looping

We've reviewed how to use Dart variables and operators to create conditional expressions. To work with variables and operators, we typically need to implement some control flow to make our Dart code take the appropriate direction in our logic.

Dart provides some control flow syntax that is very similar to other programming languages; it is as follows:

  • if-else
  • switch/case
  • Looping with for, while, and do-while
  • break and continue
  • asserts
  • Exceptions with try/catch and throw

The Dart syntax for these control flows does not have any important particularity that needs to be reviewed in detail. Please refer to the official language tour on control flows for details: https://dart.dev/guides/language/language-tour#control-flow-statements.