Semicolons in Dart are mandatory. The semicolon acts as statements terminator. That is every statement must be ended with a semicolon(;).
Dart also allows multiple statements in a single line, exception that every statement must be ended by a semicolon(;). Otherwise a compile-time error will be raised by a compiler.
int x = 45;
String planet = 'Earth ๐';
// double type
var weight = 52.22;
Every statement in above examples are ended by a semicolon.
In Dart, we can also write more than one statement on the same line, separated by semicolon(;). Check below provided example:
String name = 'Scarlett Johansson'; double height = 1.6;
Hope you like this!
Keep helping and happy ๐ coding
Related Articles
Deepen your understanding with these curated continuations.
Dart - Comments
Improve your code readability with this guide to Dart comments. Learn single-line, multi-line, and doc comments for better Flutter development maintenance.
Dart - Relational Operators
Master relational operators in Dart and Flutter. Learn how to compare values using less than, greater than, and equal to operators in your mobile apps.
Dart - Comparison Operators
Learn how to use comparison and equality operators in Dart and Flutter. Understand == and != operators with practical code examples for your next app.