asserts that ScreenUtil is called only after it was initialized
Showing
1 changed file
with
7 additions
and
1 deletions
| @@ -39,7 +39,13 @@ class ScreenUtil { | @@ -39,7 +39,13 @@ class ScreenUtil { | ||
| 39 | _textScaleFactor = window.textScaleFactor; | 39 | _textScaleFactor = window.textScaleFactor; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - factory ScreenUtil() => _instance; | 42 | + factory ScreenUtil() { |
| 43 | + assert( | ||
| 44 | + _instance != null, | ||
| 45 | + '\nEnsure to initialize ScreenUtil before accessing it.', | ||
| 46 | + ); | ||
| 47 | + return _instance; | ||
| 48 | + } | ||
| 43 | 49 | ||
| 44 | static void init({ | 50 | static void init({ |
| 45 | Size designSize = defaultSize, | 51 | Size designSize = defaultSize, |
-
Please register or login to post a comment