OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * The reserved words [:true:] and [:false:] denote objects that are the only | 8 * The reserved words [:true:] and [:false:] denote objects that are the only |
9 * instances of this class. | 9 * instances of this class. |
10 * | 10 * |
(...skipping 20 matching lines...) Expand all Loading... |
31 * | 31 * |
32 * Example: | 32 * Example: |
33 * | 33 * |
34 * const loggingFlag = const bool.fromEnvironment("logging"); | 34 * const loggingFlag = const bool.fromEnvironment("logging"); |
35 * | 35 * |
36 * If you want to use a different truth-string than `"true"`, you can use the | 36 * If you want to use a different truth-string than `"true"`, you can use the |
37 * [String.fromEnvironment] constructor directly: | 37 * [String.fromEnvironment] constructor directly: |
38 * | 38 * |
39 * const isLoggingOn = (const String.fromEnvironment("logging") == "on"); | 39 * const isLoggingOn = (const String.fromEnvironment("logging") == "on"); |
40 */ | 40 */ |
| 41 // The .fromEnvironment() constructors are special in that we do not want |
| 42 // users to call them using "new". We prohibit that by giving them bodies |
| 43 // that throw, even though const constructors are not allowed to have bodies. |
| 44 // Disable those static errors. |
| 45 //ignore: const_constructor_with_body |
| 46 //ignore: const_factory |
41 external const factory bool.fromEnvironment(String name, | 47 external const factory bool.fromEnvironment(String name, |
42 {bool defaultValue: false}); | 48 {bool defaultValue: false}); |
43 | 49 |
44 external int get hashCode; | 50 external int get hashCode; |
45 | 51 |
46 /** | 52 /** |
47 * Returns [:"true":] if the receiver is [:true:], or [:"false":] if the | 53 * Returns [:"true":] if the receiver is [:true:], or [:"false":] if the |
48 * receiver is [:false:]. | 54 * receiver is [:false:]. |
49 */ | 55 */ |
50 String toString() { | 56 String toString() { |
51 return this ? "true" : "false"; | 57 return this ? "true" : "false"; |
52 } | 58 } |
53 } | 59 } |
OLD | NEW |