flutter_shogi_board 0.0.6
flutter_shogi_board: ^0.0.6

Flutter Android iOS web

A shogi board widget for Flutter. This widget can be used to render static game board positions, tsume problems or shogi castles.

flutter_shogi_board #

A shogi board widget for Flutter. This widget can be used in conjunction with shogi to render static game board positions, tsume problems or shogi castles.

Shogi (将棋) is a two-player strategy board game native to Japan, belonging to the same family as chess and xiangqi.

Presently the package is very basic in which it can determine the static board position for a given game and move pieces from one position to another. As it is still highly experimental, 0.0.x versioning is used. shogi is also in active development and similarly versioned.

Getting Started #

Import the package #

To import this package, simply add flutter_shogi_board as a dependency in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_shogi_board:

Note that this package requires dart >= 2.7.0.

Example #

import 'package:flutter/material.dart';
import 'package:flutter_shogi_board/flutter_shogi_board.dart';
import 'package:shogi/shogi.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Center(
            child: ShogiBoard(
              gameBoard: ShogiUtils.initialBoard,
            ),
          ),
        ),
      ),
    ),
  );
}

For more information, see the Flutter app in the example directory. This example is also hosted online.

Basic Usage #

ShogiGameBoard #

This widget renders a shogi game board using a GameBoard and ShogiBoardStyle. Unless style.maxSize is set, it fills its maximum size to that of its parent. The board pieces are rendered as text.

ParameterDescription
gameBoardA GameBoard to render.
styleOptional. A style to render the shogi board, defaults to constants listed below.
showPiecesInHandOptional. Whether pieces in hand should be shown, defaults to true.

ShogiBoardStyle #

A model used to paint a ShogiBoard.

ParameterDescription
maxSizeThe maximum size of the board. Defaults to double.infinity.
pieceColorOptional. The standard piece color, defaults to black.
promotedPieceColorOptional. The promoted piece color, defaults to red.
cellColorOptional. The board cell background color, defaults to transparent.
borderColorOptional. The board cell background color, defaults to gray.
usesJapaneseOptional. Whether japanese characters or english letters are displayed, defaults to true.
showCoordIndicatorsOptional. Whether board coordinate indicators should be shown, defaults to true.
coordIndicatorTypeOptional. The type of coordinate indicators show, defaults to CoordIndicatorType.japanese.

DefaultShogiBoardStyle #

The ShogiBoardStyle to apply to descendant ShogiBoard widgets without an explicit style.

DefaultShogiBoardStyle(
  style: ShogiBoardStyle(
    cellColor: BoardColors.brown,
  ),
  child: MaterialApp(
    ...

Importing a Game Board #

Please see shogi API - Importing a Game Board for full information on how to import a game board. Here are two visual examples:

Future Plans #

This package grew out of my desired to visualize shogi castles in Flutter, and with no game board widget or even a shogi engine available, I decided to roll my own.

For the future I would like to utilize this widget not just for displaying static game boards, but also for tsume problems, thus user interaction may be considered.

Raising Issues and Contributing #

Please report bugs and issues, and raise feature requests on GitHub.

To contribute, submit a PR with a detailed description and tests, if applicable.

1
likes
105
pub points
0%
popularity

Publisher

defuncart.com

A shogi board widget for Flutter. This widget can be used to render static game board positions, tsume problems or shogi castles.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, meta, pedantic, shogi

More

Packages that depend on flutter_shogi_board