flutter_chess_board 0.2.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 83

flutter_chess_board

A Chessboard Widget for Flutter. The widget maintains game state and gives callbacks for game events like moves, checkmate and draws. This widget is still in active development.

alt text

Import the package

To use this package, add chess_board as a dependency in your pubspec.yaml

Example

    import 'package:flutter/material.dart';
    import 'package:flutter_chess_board/flutter_chess_board.dart';
    
    void main() {
      runApp(
        new MaterialApp(
          home: new Scaffold(
            body: new Center(
              child: ChessBoard(
                size: 200.0,
                onMove: (move) {
                  print(move);
                },
                onCheckMate: (color) {
                  print(color);
                },
                onDraw: () {
                  print("DRAW!");
                },
              ),
            ),
          ),
        ),
      );
    }

Board parameters:

size:

Gives length and width of chess board

onMove:

Callback for when a move is made. Returns a move as a string. E.g.: "Nf4"

onDraw:

Callback for when game becomes a draw.

onCheckMate:

Callback for when a player checkmates the other. Returns the color of the winner.

whiteSideTowardsUser:

Defines if white or black side faces user. The player is white by default(true). If set to false, black faces the user.

controller

Defines the ChessBoardController for the widget for changing the board programmatically.

enableUserMoves

Disables user moves when set to false.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

[0.2.3] - 26/08/2018.

  • Upgraded to Dart <3.0.0

example/lib/main.dart

import 'package:flutter_chess_board/flutter_chess_board.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ChessBoard(
              onMove: (move) {
                print(move);
              },
              onCheckMate: (color) {
                print(color);
              },
              onDraw: () {},
              size: MediaQuery.of(context).size.width,
              enableUserMoves: true,
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_chess_board: ^0.2.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_chess_board/flutter_chess_board.dart';
  
Version Uploaded Documentation Archive
0.2.3 Sep 4, 2018 Go to the documentation of flutter_chess_board 0.2.3 Download flutter_chess_board 0.2.3 archive
0.2.2 Aug 28, 2018 Go to the documentation of flutter_chess_board 0.2.2 Download flutter_chess_board 0.2.2 archive
0.2.1 Aug 26, 2018 Go to the documentation of flutter_chess_board 0.2.1 Download flutter_chess_board 0.2.1 archive
0.2.0 Aug 26, 2018 Go to the documentation of flutter_chess_board 0.2.0 Download flutter_chess_board 0.2.0 archive
0.1.0 Aug 26, 2018 Go to the documentation of flutter_chess_board 0.1.0 Download flutter_chess_board 0.1.0 archive
0.0.5 Aug 23, 2018 Go to the documentation of flutter_chess_board 0.0.5 Download flutter_chess_board 0.0.5 archive
0.0.4 Aug 22, 2018 Go to the documentation of flutter_chess_board 0.0.4 Download flutter_chess_board 0.0.4 archive
0.0.3 Aug 22, 2018 Go to the documentation of flutter_chess_board 0.0.3 Download flutter_chess_board 0.0.3 archive
0.0.2 Aug 22, 2018 Go to the documentation of flutter_chess_board 0.0.2 Download flutter_chess_board 0.0.2 archive
0.0.1 Aug 22, 2018 Go to the documentation of flutter_chess_board 0.0.1 Download flutter_chess_board 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
67
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Oct 26, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0-dev.7.1.flutter-b99bcfd309
  • pana: 0.12.5
  • Flutter: 0.10.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <=3.0.0
chess >=0.6.5 <1.0.0 0.6.5
chess_vectors_flutter >=1.0.6 <2.0.0 1.0.6
flutter 0.0.0
Transitive dependencies
collection 1.14.11
matcher 0.12.4
meta 1.1.6
path 1.6.2
quiver 2.0.1
sky_engine 0.0.99
stack_trace 1.9.3
tuple 1.0.2
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test