You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

2 years ago
  1. import 'package:flutter/material.dart';
  2. class Grid extends StatelessWidget {
  3. const Grid({
  4. Key? key,
  5. required this.number,
  6. required this.onTap,
  7. required this.color,
  8. required this.puzzleSize,
  9. }) : super(key: key);
  10. final Function onTap;
  11. final List<dynamic> number;
  12. final Color color;
  13. final int puzzleSize;
  14. @override
  15. Widget build(BuildContext context) {
  16. var screenSize = MediaQuery.of(context).size;
  17. return SizedBox(
  18. height: screenSize.height * 0.7,
  19. width: screenSize.width * 0.4,
  20. child: GridView.builder(
  21. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  22. crossAxisCount: puzzleSize,
  23. ),
  24. itemCount: number.length,
  25. itemBuilder: (context, index) {
  26. return number[index] != 0
  27. ? MouseRegion(
  28. child: Padding(
  29. padding: const EdgeInsets.all(2.0),
  30. child: GestureDetector(
  31. onTap: () => onTap(index),
  32. child: Card(
  33. elevation: 4,
  34. color: color,
  35. // dark -> 0xFF14407a
  36. // light -> 0xFF43b9fd
  37. shape: RoundedRectangleBorder(
  38. borderRadius: BorderRadius.circular(20),
  39. ),
  40. child: SizedBox(
  41. height: 20,
  42. width: 20,
  43. child: Center(
  44. child: Text(
  45. number[index].toString(),
  46. style: const TextStyle(
  47. fontSize: 60,
  48. fontWeight: FontWeight.bold,
  49. color: Colors.white,
  50. ),
  51. ),
  52. ),
  53. ),
  54. ),
  55. ),
  56. ),
  57. )
  58. : const SizedBox();
  59. },
  60. ),
  61. );
  62. }
  63. }