[READ ONLY MIRROR] Open Source TikTok alternative built on AT Protocol github.com/sprksocial/client
flutter atproto video dart
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';import 'package:flutter_dotenv/flutter_dotenv.dart';import 'package:material_ui/material_ui.dart';import 'package:flutter_riverpod/flutter_riverpod.dart' as riverpod;import 'package:fvp/fvp.dart' as fvp;import 'package:spark/src/core/auth/data/repositories/auth_repository.dart';import 'package:spark/src/core/auth/data/repositories/auth_repository_impl.dart';import 'package:spark/src/core/di/service_locator.dart';import 'package:spark/src/core/notifications/push_notification_service.dart';import 'package:spark/src/core/storage/cache/download_manager_interface.dart';import 'package:spark/src/core/storage/storage.dart';import 'package:spark/src/core/ui/theme/data/models/app_theme.dart';import 'package:spark/src/core/utils/logging/logging.dart';import 'package:spark/src/core/utils/logging/riverpod_logger.dart';import 'package:spark/src/sprk_app.dart';
Future<void> main() => runSparkApp();
Future<void> runSparkApp({ LocalStorageInterface? preferencesStorage, LocalStorageInterface? secureStorage, riverpod.ProviderContainer? providerContainer, Future<DownloadManagerInterface> Function()? initializeDownloadManager, Future<PushNotificationService> Function()? initializePushNotifications,}) async { final binding = WidgetsFlutterBinding.ensureInitialized(); binding.deferFirstFrame(); var didAllowFirstFrame = false;
void allowFirstFrame() { if (didAllowFirstFrame) { return; } didAllowFirstFrame = true; binding.allowFirstFrame(); }
try { await dotenv.load(); await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]);
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); SystemChrome.setSystemUIOverlayStyle(AppTheme.darkSystemUiStyle);
fvp.registerWith();
await initServiceLocator( preferencesStorage: preferencesStorage, secureStorage: secureStorage, initializeDownloadManager: initializeDownloadManager, initializePushNotifications: initializePushNotifications, );
// Setup logging for production/debug _setupLogging();
// Initialize auth repository await _initializeAuth();
// Create a ProviderContainer with the Riverpod logger final container = providerContainer ?? riverpod.ProviderContainer(observers: [SparkRiverpodLogger()]); runApp( riverpod.UncontrolledProviderScope( container: container, child: SprkApp(onFirstRouteReady: allowFirstFrame), ), ); } catch (_) { allowFirstFrame(); rethrow; }}
/// Setup logging framework based on environmentvoid _setupLogging() { sl<LogService>().setGlobalLogLevel( kDebugMode ? LogLevel.debug : LogLevel.warning, );}
/// Initialize auth repository and wait for it to be readyFuture<void> _initializeAuth() async { final logService = sl<LogService>(); final logger = logService.getLogger('AppInitialization');
try { final authRepository = sl<AuthRepository>();
if (authRepository is AuthRepositoryImpl) { await authRepository.initializationComplete; } } catch (e) { logger.e('AuthRepository initialization failed', error: e); }}