Coder Social home page Coder Social logo

dnfield / flutter-chessground Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lichess-org/flutter-chessground

0.0 1.0 0.0 1.49 MB

Chessboard package for flutter

License: GNU General Public License v3.0

Objective-C 0.08% Kotlin 0.26% Dart 98.85% Swift 0.81%

flutter-chessground's Introduction

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
  • displays a shadow under dragged piece to indicate the drop square target
  • board themes
  • promotion selector

Getting started

This package exports a Board widget which can be interactable or not. It is entirely configurable with a Settings object.

Usage

This will display a board with the starting position, using the default theme:

import 'package:flutter/material.dart';
import 'package:chessground/chessground.dart' as cg;

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  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: cg.Board(
          size: screenWidth,
          orientation: cg.Color.white,
          fen: fen,
        ),
      ),
    );
  }
}

See the example app for an interactable version against a random bot.

flutter-chessground's People

Contributors

veloce avatar schlawg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.