diff --git a/apps/client/lib/src/app/bootstrap.dart b/apps/client/lib/src/app/bootstrap.dart index b63d04f..3c8ebf5 100644 --- a/apps/client/lib/src/app/bootstrap.dart +++ b/apps/client/lib/src/app/bootstrap.dart @@ -1,4 +1,5 @@ import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -9,9 +10,7 @@ import '../integrations/proto_socket/proto_socket_endpoint_config.dart'; import '../integrations/proto_socket/proto_socket_lifecycle.dart'; import 'nomadcode_client_app.dart'; -final _mattermostHost = MattermostPushHostIntegration( - pushClient: MattermostPushPluginClient(), -); +MattermostPushHostIntegration? _mattermostHost; final _navigatorKey = GlobalKey(); /// proto-socket lifecycle wired with the concrete connector. Bootstrap does @@ -21,6 +20,12 @@ final _protoSocketLifecycle = ProtoSocketLifecycle( ); ProtoSocketEndpointConfig? _protoSocketConfig; +MattermostPushHostIntegration _ensureMattermostHost() { + return _mattermostHost ??= MattermostPushHostIntegration( + pushClient: MattermostPushPluginClient(), + ); +} + Future applyFullscreenMode() async { await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); SystemChrome.setSystemUIOverlayStyle( @@ -34,8 +39,10 @@ Future applyFullscreenMode() async { Future bootstrapNomadCodeClient() async { await applyFullscreenMode(); - await Firebase.initializeApp(); - await _mattermostHost.initialize(); + if (!kIsWeb) { + await Firebase.initializeApp(); + await _ensureMattermostHost().initialize(); + } _protoSocketConfig = ProtoSocketEndpointConfig.fromEnv(const {}); }