1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | /// A constant that is true if the application was compiled in release mode. |
6 | /// |
7 | /// More specifically, this is a constant that is true if the application was |
8 | /// compiled in Dart with the '-Ddart.vm.product=true' flag. |
9 | /// |
10 | /// Since this is a const value, it can be used to indicate to the compiler that |
11 | /// a particular block of code will not be executed in release mode, and hence |
12 | /// can be removed. |
13 | /// |
14 | /// Generally it is better to use [kDebugMode] or `assert` to gate code, since |
15 | /// using [kReleaseMode] will introduce differences between release and profile |
16 | /// builds, which makes performance testing less representative. |
17 | /// |
18 | /// See also: |
19 | /// |
20 | /// * [kDebugMode], which is true in debug builds. |
21 | /// * [kProfileMode], which is true in profile builds. |
22 | const bool kReleaseMode = bool.fromEnvironment('dart.vm.product' ); |
23 | |
24 | /// A constant that is true if the application was compiled in profile mode. |
25 | /// |
26 | /// More specifically, this is a constant that is true if the application was |
27 | /// compiled in Dart with the '-Ddart.vm.profile=true' flag. |
28 | /// |
29 | /// Since this is a const value, it can be used to indicate to the compiler that |
30 | /// a particular block of code will not be executed in profile mode, an hence |
31 | /// can be removed. |
32 | /// |
33 | /// See also: |
34 | /// |
35 | /// * [kDebugMode], which is true in debug builds. |
36 | /// * [kReleaseMode], which is true in release builds. |
37 | const bool kProfileMode = bool.fromEnvironment('dart.vm.profile' ); |
38 | |
39 | /// A constant that is true if the application was compiled in debug mode. |
40 | /// |
41 | /// More specifically, this is a constant that is true if the application was |
42 | /// not compiled with '-Ddart.vm.product=true' and '-Ddart.vm.profile=true'. |
43 | /// |
44 | /// Since this is a const value, it can be used to indicate to the compiler that |
45 | /// a particular block of code will not be executed in debug mode, and hence |
46 | /// can be removed. |
47 | /// |
48 | /// An alternative strategy is to use asserts, as in: |
49 | /// |
50 | /// ```dart |
51 | /// assert(() { |
52 | /// // ...debug-only code here... |
53 | /// return true; |
54 | /// }()); |
55 | /// ``` |
56 | /// |
57 | /// See also: |
58 | /// |
59 | /// * [kReleaseMode], which is true in release builds. |
60 | /// * [kProfileMode], which is true in profile builds. |
61 | const bool kDebugMode = !kReleaseMode && !kProfileMode; |
62 | |
63 | /// The epsilon of tolerable double precision error. |
64 | /// |
65 | /// This is used in various places in the framework to allow for floating point |
66 | /// precision loss in calculations. Differences below this threshold are safe to |
67 | /// disregard. |
68 | const double precisionErrorTolerance = 1e-10; |
69 | |
70 | /// A constant that is true if the application was compiled to run on the web. |
71 | /// |
72 | /// See also: |
73 | /// |
74 | /// * [defaultTargetPlatform], which is used by themes to find out which |
75 | /// platform the application is running on (or, in the case of a web app, |
76 | /// which platform the application's browser is running in). Can be overridden |
77 | /// in tests with [debugDefaultTargetPlatformOverride]. |
78 | /// * [dart:io.Platform], a way to find out the browser's platform that is not |
79 | /// overridable in tests. |
80 | const bool kIsWeb = bool.fromEnvironment('dart.library.js_util' ); |
81 | |