main function

void main()

Método principal de la aplicación: Inicio de la app.

Este método inicializa la base de datos y las preferencias, y luego ejecuta la aplicación en un MultiProvider que maneja el estado global de la aplicación.

Implementation

void main() async {
  // ASEGURA LA INICIACION DE LOS BINDING
  WidgetsFlutterBinding.ensureInitialized();
  // SE INICIALIZA LA BASE DE DATOS Y SE CONFIGURA LAS PREFERENCIAS
  await DatabaseHelper.initDatabase();
  await SettingsScreenState.startPreferences();
  await AppNotification.startPreferences();
  await ConfigurationTimer.startPreferences();
  await UserClass.startPreferences();

  // INICIALIZAR EL TIMEZONES
  tz.initializeTimeZones();

  // SE INICIALIZAN LAS NOTIFICACIONES DONDE TE PIDE LOS PERMISOS
  await NotificationService.initNotification();

  // QUITA EL STATUS BAR EN EL MOVIL
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);

  // CARGAMOS EL ARCHIVO .env
  await dotenv.load(fileName: ".env");

  // INICIALIZAMOS Supabase CON LAS VARIABLES DE ENTORNO
  await Supabase.initialize(
    url: dotenv.env['SUPABASE_URL']!,
    anonKey: dotenv.env['SUPABASE_ANON_KEY']!,
  );

  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => CurrentCubeType()),
        ChangeNotifierProvider(create: (_) => CurrentTime()),
        ChangeNotifierProvider(create: (_) => CurrentLanguage()),
        ChangeNotifierProvider(create: (_) => CurrentNotifications()),
        ChangeNotifierProvider(create: (_) => CurrentConfigurationTimer()),
        ChangeNotifierProvider(create: (_) => CurrentStatistics()),
        ChangeNotifierProvider(create: (_) => CurrentScramble()),
        ChangeNotifierProvider(create: (_) => CurrentSession()),
        ChangeNotifierProvider(create: (context) => CurrentUser()),
        // INICIAR EL CONTADOR CUANDO INICIE LA APP
        ChangeNotifierProvider(create: (context) => CurrentUsageTimer()..start()),
      ],
      child: const CubeXApp(), // SE INICIA LA APLICACIÓN
    ),
  ); // SE INICIA LA APLICACION DENTRO DE UN PROVIDER PARA GESTIONAR EL USUARIO
}