// ============================================================ // main.dart — App Recolecta (corregido) // Cambios aplicados: // 1. Agregados imports faltantes (material, riverpod) // 2. Corregido ColorScheme.fromSeed (faltaba el tipo) // 3. Corregido MainAxisAlignment.center (faltaba el tipo) // 4. Agregado WidgetsFlutterBinding.ensureInitialized() antes de dotenv // ============================================================ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; Future main() async { // NECESARIO antes de cualquier async en main (inicializa el motor de Flutter) WidgetsFlutterBinding.ensureInitialized(); // Carga el .env desde assets/ await dotenv.load(fileName: "assets/.env"); runApp(const ProviderScope(child: MyApp())); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Recolecta', theme: ThemeData( // ❌ ANTES: colorScheme: .fromSeed(seedColor: Colors.deepPurple), // ✅ AHORA: faltaba el tipo ColorScheme antes del .fromSeed colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage(title: 'Recolecta - Demo'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: Center( child: Column( // ❌ ANTES: mainAxisAlignment: .center, // ✅ AHORA: faltaba el tipo MainAxisAlignment antes del .center mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('You have pushed the button this many times:'), Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } }