June 2017
Intermediate to advanced
873 pages
18h 9m
English
Enum does not exist in Dart as a built-in type. Enums provide additional type checking and thus, help enhance code maintainability. So what alternative do we have? Look at the code in project enum, where we want to differentiate the degree of an issue reported to us (we distinguish between the following levels: TRIVIAL, REGU
LAR, IMPO
RTANT, and CRITICAL).
The first way to achieve the creating an enum functionality is shown in enu
m1.dart:
class IssueDegree { final _value; const IssueDegree(this._value); toString() => 'Enum.$_value'; static const TRIVIAL = const IssueDegree('TRIVIAL'); static const REGULAR = const IssueDegree('REGULAR'); static const IMPORTANT = const IssueDegree('IMPORTANT'); static const CRITICAL ...
Read now
Unlock full access