import 'package:flame/sprite.dart'; import 'package:flutter/material.dart'; import 'package:match_magic/game/sprite_loader.dart'; import 'package:provider/provider.dart'; import 'game/match_magic_game.dart'; import 'game/swap_notifier.dart'; void main() { runApp( MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => SwapNotifier()), ], child: const MyApp(), ), ); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Match Magic', theme: ThemeData( primarySwatch: Colors.blue, ), home: const Scaffold( body: MatchMagicGameScreen(), ), ); } } class MatchMagicGameScreen extends StatelessWidget { const MatchMagicGameScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return FutureBuilder>( future: SpriteLoader.loadSprites(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { return Center(child: Text('Error: ${snapshot.error}')); } else if (!snapshot.hasData || snapshot.data == null) { return const Center(child: Text('No sprites found')); } else { final sprites = snapshot.data!; return Center( child: AspectRatio( aspectRatio: 1, child: MatchMagicGame(sprites: sprites), ), ); } } else { return const Center(child: CircularProgressIndicator()); } }, ); } }