flutter_chessboard_js 0.0.2+7 copy "flutter_chessboard_js: ^0.0.2+7" to clipboard
flutter_chessboard_js: ^0.0.2+7 copied to clipboard

A chessboard widget to use with chessjs. Use chessjs for the logic of the game, and this package to display the game.

example/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:chessjs/chessjs.dart' as chessjs;
import 'package:flutter_chessboard_js/flutter_chessboard_js.dart' as chessboard;

void main() {
  runApp(MyApp());
}

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

class ChessGame extends StatefulWidget {
  @override
  _ChessGameState createState() => _ChessGameState();
}

class _ChessGameState extends State<ChessGame> {
  String? move;

  @override
  Widget build(BuildContext context) {
    final chessboard.ChessboardController chessboardController =
        chessboard.ChessboardController(
            chessjsGame: chessjs.Chess(),
            onMove: (move) {
              print('move: $move');
            });
    return Scaffold(
      backgroundColor: Colors.black,
      body: SizedBox.expand(
        child: Theme(
          data: ThemeData.dark(),
          child: Row(
            children: [
              chessboard.ChessBoard(
                initialSize: 400,
                minSize: 300,
                controller: chessboardController,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
110
pub points
0%
popularity

Publisher

verified publishercarlosalejano.app

A chessboard widget to use with chessjs. Use chessjs for the logic of the game, and this package to display the game.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

chessjs, flutter, tuple

More

Packages that depend on flutter_chessboard_js