Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lichess-org/flutter-chessground
Chessboard package for flutter
https://github.com/lichess-org/flutter-chessground
chessboard dart flutter lichess
Last synced: about 7 hours ago
JSON representation
Chessboard package for flutter
- Host: GitHub
- URL: https://github.com/lichess-org/flutter-chessground
- Owner: lichess-org
- License: gpl-3.0
- Created: 2022-05-03T16:30:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T14:31:04.000Z (6 months ago)
- Last Synced: 2024-05-14T15:39:29.132Z (6 months ago)
- Topics: chessboard, dart, flutter, lichess
- Language: Dart
- Homepage:
- Size: 38.3 MB
- Stars: 35
- Watchers: 10
- Forks: 21
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Tests](https://github.com/lichess-org/flutter-chessground/workflows/Test/badge.svg)](https://github.com/lichess-org/flutter-chessground/actions?query=workflow%3A%22Test%22)
[![pub package](https://img.shields.io/pub/v/chessground.svg)](https://pub.dev/packages/chessground)
[![package publisher](https://img.shields.io/pub/publisher/chessground.svg)](https://pub.dev/packages/chessground/publisher)
[![Discord](https://img.shields.io/discord/280713822073913354?label=Discord&logo=discord&style=flat)](https://discord.com/channels/280713822073913354/807722604478988348)Chessground is a chessboard package developed for lichess.org. It doesn't handle
chess logic so you can use it with different chess variants.## Features
- pieces animations: moving and fading away
- board highlights: last move, piece destinations
- move piece by tap or drag and drop
- premoves
- displays a shadow under dragged piece to indicate the drop square target
- board themes
- piece sets from lichess
- promotion selector
- draw shapes on board while playing using 2 fingers
- move annotations
- opponent's pieces can be displayed upside down
- create positions with a board editor## Getting started
This package exports a `Chessboard` widget which can be interactable or not.
It is configurable with a `ChessboardSettings` object which defines the board
behavior and appearance.To interact with the board in order to play a game, you must provide a `GameData`
object to the `Chessboard` widget. This object is immutable and contains the game
state (which side is to move, the current valid moves, etc.), along with the
callback functions to handle user interactions.All chess logic must be handled outside of this package. Any change in the state
of the game needs to be transferred to the board by creating a new `GameData` object.## Usage
This will display a non-interactable board from the starting position, using the
default theme:```dart
import 'package:flutter/material.dart';
import 'package:chessground/chessground.dart';class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);@override
State createState() => _MyHomePageState();
}class _MyHomePageState extends State {
String fen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR';@override
Widget build(BuildContext context) {
final double screenWidth = MediaQuery.of(context).size.width;return Scaffold(
appBar: AppBar(
title: const Text('Chessground demo'),
),
body: Center(
child: Chessboard.fixed(
size: screenWidth,
orientation: Side.white,
fen: fen,
),
),
);
}
}
```See the example app for:
- Random Bot: an interactable board for one player playing against a random bot,
- Free Play: an interactable board for two players sitting opposite to each other,
- Board editor: a board editor to create positions,
- Draw Shapes: activate the draw shapes feature and draw on the board using 2
- Board Thumbnails: a demo screen showing over hundred different boards in a grid,
fingers.