Closed satvikreddy closed 2 weeks ago
Hi ! Indeed, I removed it in the latest versions.
Le mar. 23 juil. 2024 à 13:16, Satvik @.***> a écrit :
in the zap https://zapp.run/edit/simple-chess-boad-z62a06g862b0?file=lib/main.dart&entry=lib/main.dart click to move and drag to move both work. That is using the old simple_chess_board: 0.6.2
But click to move is not working in the latest version.
Is this by design or is this a bug? Code given in example Code
import 'package:flutter/material.dart'; import 'package:simple_chess_board/models/board_arrow.dart'; import 'package:chess/chess.dart' as chesslib; import 'package:simple_chess_board/simple_chess_board.dart';
void main() { runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({super.key});
@override Widget build(BuildContext context) { return MaterialApp( title: 'Simple chess board Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Simple chess board Page'), ); } }
class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title});
final String title;
@override State
createState() => _MyHomePageState(); } class _MyHomePageState extends State
{ final _chess = chesslib.Chess.fromFEN(chesslib.Chess.DEFAULT_POSITION); var _blackAtBottom = false; BoardArrow? _lastMoveArrowCoordinates; late ChessBoardColors _boardColors; @override void initState() { _boardColors = ChessBoardColors() ..lightSquaresColor = Colors.blue.shade200 ..darkSquaresColor = Colors.blue.shade600 ..coordinatesZoneColor = Colors.redAccent.shade200 ..lastMoveArrowColor = Colors.cyan ..startSquareColor = Colors.orange ..endSquareColor = Colors.green ..circularProgressBarColor = Colors.red ..coordinatesColor = Colors.green; super.initState(); }
void tryMakingMove({required ShortMove move}) { final success = _chess.move(<String, String?>{ 'from': move.from, 'to': move.to, 'promotion': move.promotion?.name, }); if (success) { setState(() { _lastMoveArrowCoordinates = BoardArrow(from: move.from, to: move.to); }); } }
Future<PieceType?> handlePromotion(BuildContext context) { final navigator = Navigator.of(context); return showDialog
( context: context, builder: (_) { return AlertDialog( title: const Text('Promotion'), content: Column( mainAxisSize: MainAxisSize.min, children: [ ListTile( title: const Text("Queen"), onTap: () => navigator.pop(PieceType.queen), ), ListTile( title: const Text("Rook"), onTap: () => navigator.pop(PieceType.rook), ), ListTile( title: const Text("Bishop"), onTap: () => navigator.pop(PieceType.bishop), ), ListTile( title: const Text("Knight"), onTap: () => navigator.pop(PieceType.knight), ), ], ), ); }, ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), actions: [ IconButton( onPressed: () { setState(() { _blackAtBottom = !_blackAtBottom; }); }, icon: const Icon(Icons.swap_vert), ) ], ), body: Center( child: SimpleChessBoard( chessBoardColors: _boardColors, engineThinking: false, fen: _chess.fen, onMove: tryMakingMove, blackSideAtBottom: _blackAtBottom, whitePlayerType: PlayerType.human, blackPlayerType: PlayerType.human, lastMoveToHighlight: _lastMoveArrowCoordinates, onPromote: () => handlePromotion(context), onPromotionCommited: ({ required ShortMove moveDone, required PieceType pieceType, }) { moveDone.promotion = pieceType; tryMakingMove(move: moveDone); }), ), ); } }
— Reply to this email directly, view it on GitHub https://github.com/loloof64/Flutter-Simple-Chess-Board/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN55P7JGHIJQ7GZ4JXLA53ZNY3Q7AVCNFSM6AAAAABLKGQCGOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZDIOJTG4ZDKNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Cordialement,
Laurent Bernabé
@.***
in the zap click to move and drag to move both work. That is using the old
simple_chess_board: 0.6.2
But click to move is not working in the latest version.
Is this by design or is this a bug?
Code given in example
### Code ``` import 'package:flutter/material.dart'; import 'package:simple_chess_board/models/board_arrow.dart'; import 'package:chess/chess.dart' as chesslib; import 'package:simple_chess_board/simple_chess_board.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Simple chess board Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Simple chess board Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State