pourquoi quand je vais sur la page classement j'ai cette erreur : E/SQLiteLog(11457): (1) no such table: classement voici l'appli : import 'package:flutter/material.dart';
import 'package:flutter_snake/UI/home.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Future<Database> database = openDatabase(
    join(await getDatabasesPath(), 'snake_database.db'),
    onCreate: (db, version) {
      return db.transaction((txn) async {
        await txn.execute(
          'CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT)',
        );
        await txn.execute(
          'CREATE TABLE scores(id INTEGER PRIMARY KEY, userId INTEGER, score INTEGER, FOREIGN KEY(userId) REFERENCES users(id))',
        );
        await txn.execute(
            'CREATE TABLE classement(id INTEGER PRIMARY KEY, userId INTEGER, score INTEGER, FOREIGN KEY(userId) REFERENCES users(id), FOREIGN KEY(score) REFERENCES scores(id))');
      });
    },
    version: 1,
  );

  runApp(MyApp(database: database));
}

class MyApp extends StatelessWidget {
  final Future<Database> database;

  const MyApp({Key? key, required this.database}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(database: database),
    );
  }
}
import 'package:flutter/material.dart';
import 'package:flutter_snake/ui/snake_page.dart';
import 'package:flutter_snake/ui/classement_page.dart';
import 'package:sqflite_common/sqlite_api.dart';

class MyHomePage extends StatefulWidget {
  final Future<Database> database;

  const MyHomePage({Key? key, required this.database}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;
  late List<Widget> _children; // Declare _children as late
  late Database db;
  String username = '';

  @override
  void initState() {
    super.initState();
    widget.database.then((database) {
      db = database;
      _showUsernameDialog();
      _children = [
        // Initialize _children here
        SnakePage(),
        ClassementPage(database: widget.database),
      ];
    });
  }

  void _showUsernameDialog() {
    showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: Text('Entrez votre pseudonyme : '),
          content: TextField(
            onChanged: (value) {
              username = value;
            },
          ),
          actions: [
            ElevatedButton(
              child: Text('OK'),
              onPressed: () async {
                Navigator.of(context).pop();
                await db.insert(
                  'users',
                  {'name': username},
                  conflictAlgorithm: ConflictAlgorithm.replace,
                );
                setState(() {}); // Add this line
              },
            ),
          ],
        );
      },
    );
  }
  //  on met les pages ici après

  void onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Bienvenue $username'),
            ElevatedButton(
              child: Text('Jouer'),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => SnakePage()),
                );
              },
            ),
            ElevatedButton(
              child: Text('Classement'),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) =>
                        ClassementPage(database: widget.database),
                  ),
                );
              },
            ),
            ElevatedButton(
              child: Text('Règles'),
              onPressed: () {
                // Remplacez ceci par la navigation vers votre page de règles
              },
            ),
          ],
        ),
      ),
    );
  }
}
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common/sqlite_api.dart';
import 'package:flutter/material.dart';

class ClassementPage extends StatefulWidget {
  final Future<Database> database;

  const ClassementPage({Key? key, required this.database}) : super(key: key);
  @override
  _ClassementPageState createState() => _ClassementPageState();
}

class _ClassementPageState extends State<ClassementPage> {
  late Future<List<Map<String, dynamic>>> futureClassement;

  @override
  void initState() {
    super.initState();
    futureClassement = getClassement();
  }

  Future<List<Map<String, dynamic>>> getClassement() async {
    final db = await widget.database;
    return db.rawQuery('SELECT * FROM classement ORDER BY score DESC');
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<List<Map<String, dynamic>>>(
      future: futureClassement,
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(child: CircularProgressIndicator());
        } else if (snapshot.hasError) {
          return Center(child: Text('Error: ${snapshot.error}'));
        } else {
          return DataTable(
            columns: const [
              DataColumn(label: Text('Position')),
              DataColumn(label: Text('Pseudo')),
              DataColumn(label: Text('Score')),
            ],
            rows: List<DataRow>.generate(
              snapshot.data!.length,
              (index) => DataRow(
                cells: [
                  DataCell(Text('${index + 1}')),
                  DataCell(Text('${snapshot.data![index]['userId']}')),
                  DataCell(Text('${snapshot.data![index]['score']}')),
                ],
              ),
            ),
          );
        }
      },
    );
  }
}