@@ -35,6 +35,13 @@ abstract class Prefs {
3535 @visibleForTesting
3636 static bool warnIfPrefAccessedBeforeLoaded = true ;
3737
38+ /// Returns whether you can use Prefs.
39+ ///
40+ /// This may be false if [init] has not been called yet,
41+ /// or on a non-main isolate.
42+ static bool get available => _available;
43+ static bool _available = false ;
44+
3845 static late final PlainPref <String ?> customDataDir;
3946
4047 static late final EncPref <bool > allowInsecureConnections;
@@ -118,6 +125,8 @@ abstract class Prefs {
118125 lastPencilColor,
119126 lastShapePenColor;
120127 static late final PlainPref <CanvasBackgroundPattern > lastBackgroundPattern;
128+ static const defaultLineHeight = 40 ;
129+ static const defaultLineThickness = 3 ;
121130 static late final PlainPref <int > lastLineHeight;
122131 static late final PlainPref <int > lastLineThickness;
123132 static late final PlainPref <bool > lastZoomLock,
@@ -156,6 +165,8 @@ abstract class Prefs {
156165 static late final PlainPref <String > locale;
157166
158167 static void init () {
168+ _available = true ;
169+
159170 customDataDir = PlainPref ('customDataDir' , null );
160171 allowInsecureConnections = EncPref ('allowInsecureConnections' , false );
161172 url = EncPref ('url' , '' );
@@ -247,8 +258,8 @@ abstract class Prefs {
247258
248259 lastBackgroundPattern =
249260 PlainPref ('lastBackgroundPattern' , CanvasBackgroundPattern .none);
250- lastLineHeight = PlainPref ('lastLineHeight' , 40 );
251- lastLineThickness = PlainPref ('lastLineThickness' , 3 );
261+ lastLineHeight = PlainPref ('lastLineHeight' , defaultLineHeight );
262+ lastLineThickness = PlainPref ('lastLineThickness' , defaultLineThickness );
252263 lastZoomLock = PlainPref ('lastZoomLock' , false );
253264 lastSingleFingerPanLock = PlainPref ('lastSingleFingerPanLock' , false ,
254265 historicalKeys: const ['lastPanLock' ]);
0 commit comments