flutter_shogi_board 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new44

flutter_shogi_board #

A shogi board widget for Flutter. This widget can be used 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.

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.3.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(
              boardPieces: ShogiUtils.initialBoard,
            ),
          ),
        ),
      ),
    ),
  );
}

For more information, see the Flutter app in the example directory.

Game Board Parameters #

The widget is designed to be used in portrait mode, and fills the board size to match it's parents width. The board pieces are rendered as text.

ParameterDescription
boardPiecesA List<BoardPiece> to render on the shogi game board.
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.

Importing a Game Board #

As the game board is presently static, a board position can be notated by {PieceType}-{Row}{Column}, i.e. K-59. Note that 11 is the top left board cell as per japanese notation.

final yagura = ['L-99', 'N-89', 'K-88', 'G-78', 'P-97', 'P-87', 'S-77', 'G-67', 'P-76', 'P-66', 'P-56'];

final boardPieces = ShogiUtils.stringArrayToBoardPiecesArray(yagura);

If sente or gote aren't specified, then sente is chosen by default. To import pieces for both players, use the notation {Player}:{PieceType}-{Row}{Column}.

final tsume1 = ['G:K-51', 'G:S-61', 'G:S-41', 'S:+P-53', 'S:+B-25'];

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. The package shogi contains the initial business logic from this package and will be simultaneously developed upon.

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.

Moreover, presently the numbers 1-9 and 一, 二, 三, 四, 五, 六, 七, 八, 九 are not displayed to mark cell positions, this is something that could be offered as an optional boolean defaulting to true.

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.

[0.0.3] - 13/10/2019

  • Moved business logic components from this package to new shogi package.

[0.0.2] - 06/10/2019

  • Fixed meta package version conflict ^1.1.7 with Flutter: 1.7.8+hotfix.4.

[0.0.1] - 06/10/2019

  • Initial release of flutter_shogi_board package for Flutter.

example/README.md

example #

A Flutter project which demonstrates the flutter_shogi_board package.

Getting Started #

For help getting started with Flutter, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_shogi_board: ^0.0.3

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_shogi_board/flutter_shogi_board.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/src/utils/package_utils.dart.

Run flutter format to format lib/src/utils/package_utils.dart.

Format lib/src/widgets/board_cell.dart.

Run flutter format to format lib/src/widgets/board_cell.dart.

Format lib/src/widgets/shogi_board.dart.

Run flutter format to format lib/src/widgets/shogi_board.dart.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: shogi.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.7
shogi any 0.0.1
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test