flutter_chess_board 0.9.4

flutter_chess_board #

A Chessboard Widget for Flutter. The widget maintains game state and gives callbacks for game events like moves, checkmate and draws. Under final testing before 1.0.

alt text

alt text

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

boardType: #

Type of board to display (Brown, Green, etc.)

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.9.4] - 06/02/2019.

  • Changed sdk dependencies
  • Added board colors
  • Changed architecture to ScopedModel
  • Fixed controller bug
  • Added screenshots

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_chess_board/src/chess_board.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.9.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
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]
85
Learn more about scoring.

We analyzed this package on Jul 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >2.0.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.10
flutter 0.0.0
scoped_model >=1.0.0 <2.0.0 1.0.1
Transitive dependencies
collection 1.14.11
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.2
quiver 2.0.3
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

Admin