orientação

This commit is contained in:
2026-03-22 15:28:56 +00:00
parent 00fee30792
commit be103c66b0

View File

@@ -1,21 +1,27 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; // Para as orientações
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:playmaker/classe/theme.dart'; // 👇 IMPORTA O TEU TEMA import 'package:playmaker/classe/theme.dart';
import 'pages/login.dart'; import 'pages/login.dart';
// ======================================================== // Variável global para controlar o Tema
// 👇 A VARIÁVEL MÁGICA QUE FALTAVA (Fora do void main) 👇
// ========================================================
final ValueNotifier<ThemeMode> themeNotifier = ValueNotifier(ThemeMode.system); final ValueNotifier<ThemeMode> themeNotifier = ValueNotifier(ThemeMode.system);
void main() async { void main() async {
// 1. Inicializa os bindings do Flutter
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// 2. Inicializa o Supabase
await Supabase.initialize( await Supabase.initialize(
url: 'https://sihwjdshexjyvsbettcd.supabase.co', url: 'https://sihwjdshexjyvsbettcd.supabase.co',
anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaHdqZHNoZXhqeXZzYmV0dGNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MTQxMjgsImV4cCI6MjA4NDQ5MDEyOH0.gW3AvTJVNyE1Dqa72OTnhrUIKsndexrY3pKxMIAaAy8', anonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaHdqZHNoZXhqeXZzYmV0dGNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5MTQxMjgsImV4cCI6MjA4NDQ5MDEyOH0.gW3AvTJVNyE1Dqa72OTnhrUIKsndexrY3pKxMIAaAy8',
); );
// 3. Deixa a orientação livre (Portrait) para o arranque da App
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
runApp(const MyApp()); runApp(const MyApp());
} }
@@ -24,7 +30,6 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// FICA À ESCUTA DO THEMENOTIFIER
return ValueListenableBuilder<ThemeMode>( return ValueListenableBuilder<ThemeMode>(
valueListenable: themeNotifier, valueListenable: themeNotifier,
builder: (_, ThemeMode currentMode, __) { builder: (_, ThemeMode currentMode, __) {
@@ -33,7 +38,7 @@ class MyApp extends StatelessWidget {
title: 'PlayMaker', title: 'PlayMaker',
theme: AppTheme.lightTheme, theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme, darkTheme: AppTheme.darkTheme,
themeMode: currentMode, // 👇 ISTO RECEBE O VALOR DO NOTIFIER themeMode: currentMode,
home: const LoginPage(), home: const LoginPage(),
); );
}, },