import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class AppCustomCheckbox extends StatelessWidget { final String label; final bool value; final ValueChanged onChanged; final double checkboxSize; final double checkmarkSizeFactor; const AppCustomCheckbox({ super.key, required this.label, required this.value, required this.onChanged, this.checkboxSize = 20.0, this.checkmarkSizeFactor = 1.4, }); @override Widget build(BuildContext context) { return GestureDetector( onTap: () => onChanged(!value), // Inverse la valeur au clic behavior: HitTestBehavior.opaque, // Pour s'assurer que toute la zone du Row est cliquable child: Row( mainAxisSize: MainAxisSize.min, children: [ SizedBox( width: checkboxSize, height: checkboxSize, child: Stack( alignment: Alignment.center, clipBehavior: Clip.none, children: [ Image.asset( 'assets/images/square.png', height: checkboxSize, width: checkboxSize, ), if (value) Image.asset( 'assets/images/coche.png', height: checkboxSize * checkmarkSizeFactor, width: checkboxSize * checkmarkSizeFactor, ), ], ), ), const SizedBox(width: 10), // Utiliser Flexible pour que le texte ne cause pas d'overflow si trop long Flexible( child: Text( label, style: GoogleFonts.merienda(fontSize: 14), overflow: TextOverflow.ellipsis, // Gérer le texte long ), ), ], ), ); } }