Another exception was thrown: type '_Map<String, bool>' is not a subtype of type 'Map<String, String>' in type cast. import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

import 'package:sae_mobile/views/signout.dart';

import 'package:sae_mobile/models/User.dart' as user_model;

final SupabaseClient supabaseClient = Supabase.instance.client;

class ProfileView extends StatefulWidget {
  final user_model.User user;
  const ProfileView({super.key, required this.user});

  @override
  State<ProfileView> createState() => _ProfileState();
}

class _ProfileState extends State<ProfileView> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Text('Profile'),
        Text('Email: ${widget.user.email}'),
        Text('Name: ${widget.user.username}'),
        const SignOut(),
        SizedBox(height: 20),
        // Add your buttons
        ElevatedButton(
          style: ElevatedButton.styleFrom(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(20),
            ),
            minimumSize: Size(double.infinity, 50),
          ),
          onPressed: () {
            Navigator.pushNamed(context, '/annonces', arguments: {
              'isUserAnnonces': false,
              'isReponduAnnonces': true
            });
          },
          child: Text('Mes Reservations'),
        ),
        SizedBox(height: 10),
        ElevatedButton(
          style: ElevatedButton.styleFrom(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(20),
            ),
            minimumSize: Size(double.infinity, 50),
          ),
          onPressed: () {
            Navigator.pushNamed(context, '/annonces', arguments: {
              'isUserAnnonces': true,
              'isReponduAnnonces': false
            });
          },
          child: Text('Mes Annonces'),
        ),
      ],
    );
  }
}
import 'package:flutter/material.dart';
import 'package:sae_mobile/models/Builder.dart' as builder_model;
import 'package:sae_mobile/views/annonceTile.dart';
import 'package:sae_mobile/models/annonce.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

final SupabaseClient supabaseClient = Supabase.instance.client;

class AnnoncesView extends StatefulWidget {
  final String categoryId;
  final String categoryName;
  final bool isUserAnnonces;
  final bool isReponduAnnonces;

  const AnnoncesView(
      {Key? key,
      required this.categoryId,
      required this.categoryName,
      this.isUserAnnonces = false,
      this.isReponduAnnonces = false})
      : super(key: key);

  @override
  State<AnnoncesView> createState() => _AnnoncesViewState();
}

class _AnnoncesViewState extends State<AnnoncesView> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.categoryName),
      ),
      body: FutureBuilder(
        future: widget.isUserAnnonces
            ? builder_model.Builder.buildAnnoncesLocalUtilisateur(
                supabaseClient.auth.currentUser!.id,
              )
            : widget.isReponduAnnonces
                ? builder_model.Builder.buildAnnoncesDistantRepondu(
                    supabaseClient.auth.currentUser!.id,
                  )
                : builder_model.Builder.buildAnnoncesDistantByType(
                    widget.categoryId,
                  ),
        builder: (context, AsyncSnapshot<List<Annonce>> snapshot) {
          if (snapshot.hasError) {
            return Center(child: Text('Error: ${snapshot.error}'));
          } else {
            if (snapshot.data == null || snapshot.data!.isEmpty) {
              return Center(child: Text("Pas d'annonces"));
            } else {
              return ListView.builder(
                itemCount: snapshot.data!.length,
                itemBuilder: (context, index) {
                  final annonce = snapshot.data![index];
                  return Container(
                    height: 200,
                    child: Card(
                      margin: EdgeInsets.all(10.0),
                      child: Row(
                        children: <Widget>[
                          ClipRRect(
                            borderRadius: BorderRadius.circular(10.0),
                            child: Image.asset(
                              'images/box_base.png',
                              width: 100,
                              height: 100,
                              fit: BoxFit.cover,
                            ),
                          ),
                          Expanded(
                            child: AnnonceTile(annonce: annonce),
                          ),
                        ],
                      ),
                    ),
                  );
                },
              );
            }
          }
        },
      ),
    );
  }
}