Skip to main content

fuzo_soccer_board 0.5.0 copy "fuzo_soccer_board: ^0.5.0" to clipboard
fuzo_soccer_board: ^0.5.0 copied to clipboard

Flutter widget for a tactical soccer/football board with drag-and-drop player positioning, tactical zones, field orientation (portrait/landscape), and read-only mode. Perfect for lineup and formation editors.

fuzo_soccer_board #

Flutter widget library for tactical soccer/football boards with drag-and-drop positioning, tactical zones, formation helpers, portrait/landscape layouts, and an optional roster sidebar.

Ideal for lineup editors, coaching tools, match-planning screens, and sports apps that need an interactive field.

Features #

  • Drag players from a sidebar onto the field
  • Move players inside the field and remove them again
  • Portrait and landscape field orientations
  • Dynamic layout with sidebar priority given to the field
  • Optional field-only mode
  • Read-only mode
  • Tactical zone overlay and automatic position detection
  • Formation calculation helpers
  • Formation indicator chips on the field
  • Official pitch aspect ratio (105:68)
  • Persistence-ready Player.toJson() / Player.fromJson()
  • Configurable player rendering (card or circular)

Installation #

Add this to your pubspec.yaml:

dependencies:
  fuzo_soccer_board: ^0.2.0

Then run:

flutter pub get

Quick Start #

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

class MyBoard extends StatefulWidget {
  const MyBoard({super.key});

  @override
  State<MyBoard> createState() => _MyBoardState();
}

class _MyBoardState extends State<MyBoard> {
  List<Player> players = [
    Player(id: '1', name: 'Lionel Messi', number: 10, preferredPosition: 'RW'),
    Player(id: '2', name: 'Cristiano Ronaldo', number: 7, preferredPosition: 'ST'),
    Player(id: '3', name: 'Kevin De Bruyne', number: 17, preferredPosition: 'CM'),
    Player(id: '4', name: 'Virgil van Dijk', number: 4, preferredPosition: 'CB'),
    Player(id: '5', name: 'Manuel Neuer', number: 1, preferredPosition: 'GK'),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SoccerBoardWrapper(
          orientation: FieldOrientation.landscape,
          players: players,
          sidebarPosition: SidebarPosition.auto,
          showTacticalZones: false,
          maxPlayersPerSide: 7,
          onPlayerTap: (player) {
            // Open your own UI here if needed.
          },
          onPlayerPositioned: (playerId, fieldX, fieldY, side, position) {
            setState(() {
              players = players.map((p) {
                if (p.id != playerId) return p;
                return p.positionOnField(
                  x: fieldX,
                  y: fieldY,
                  side: side,
                  position: position,
                );
              }).toList();
            });
          },
          onPlayerRemoved: (playerId) {
            setState(() {
              players = players.map((p) {
                if (p.id != playerId) return p;
                return p.removeFromField();
              }).toList();
            });
          },
          onSidebarReset: () {
            setState(() {
              players = players.map((p) => p.removeFromField()).toList();
            });
          },
          onSidebarSave: () {
            // Persist the current board state.
          },
          onSidebarPublish: () {
            // Trigger your publish/share flow.
          },
        ),
      ),
    );
  }
}

How It Works #

  • A Player with fieldX, fieldY, and side set is rendered on the field.
  • A Player without those values is treated as available and appears in the sidebar.
  • onPlayerPositioned is where your app should update state after a drop.
  • onPlayerRemoved is where your app should remove a player from the field.
  • onPlayerTap lets your app open any custom UI, like a bottom sheet or player editor.

Player Model #

Minimum useful fields:

Player(
  id: '10',
  name: 'Lionel Messi',
  number: 10,
  preferredPosition: 'RW',
)

Important fields:

  • id: unique player id
  • name: display name
  • number: shirt number
  • photo: optional image URL/path for card mode
  • preferredPosition: preferred role such as GK, CB, CM, RW, ST
  • fieldPosition: detected tactical position on the field
  • fieldX / fieldY: normalized coordinates from 0 to 100
  • side: TeamSide.home or TeamSide.away

Main Widget #

Most apps should use SoccerBoardWrapper.

Common Parameters #

Parameter Type Default Description
orientation FieldOrientation FieldOrientation.landscape Field orientation
players List<Player> const [] Full player list
sidebarPosition SidebarPosition SidebarPosition.auto Sidebar placement
showOnlyFieldPlayers bool false Hide sidebar and show only field players
readOnly bool false Disable dragging and dropping
showTacticalZones bool false Show tactical overlays
sideFilter FieldSideFilter FieldSideFilter.both Show both halves or a single side
maxPlayersPerSide int 7 Max players allowed per side
fieldDesign FieldDesign FieldDesign.stripes Grass rendering style
playerShape PlayerShape PlayerShape.card Player token style
showFormationIndicator bool false Show formation chips on the field
showTeamNames bool true Show team names on the field independently from formation
homeFormation String? null Home formation label
awayFormation String? null Away formation label
homeTeamName String? null Home team name shown next to formation
awayTeamName String? null Away team name shown next to formation
onPlayerTap Function(Player)? null Tap callback
onPlayerPositioned OnPlayerPositioned? null Drop callback
onPlayerRemoved OnPlayerRemoved? null Remove callback
onFormationChanged OnFormationChanged? null Formation change callback
onSidebarReset VoidCallback? null Sidebar reset callback
onSidebarSave VoidCallback? null Sidebar save callback
onSidebarPublish VoidCallback? null Sidebar publish callback

Layout Behavior #

  • SidebarPosition.auto uses screen orientation:
  • Portrait screen: sidebar goes to the bottom
  • Landscape screen: sidebar goes to the left
  • The field has layout priority and keeps its official aspect ratio whenever possible
  • The field is rectangular, not rounded

Formations #

The package exports FormationHelper, which can derive formations from players currently on the field.

Example:

final homeFormation = FormationHelper.fromPlayers(
  players.where((p) => p.side == TeamSide.home && p.isOnField).toList(),
);

You can then pass that value into homeFormation / awayFormation, optionally provide homeTeamName / awayTeamName, and enable showFormationIndicator.

If you want only the team names without showing formations, set:

SoccerBoardWrapper(
  showTeamNames: true,
  showFormationIndicator: false,
  homeTeamName: 'Club Local',
  awayTeamName: 'Club Visitante',
)

Position Labels and Locale Notes #

  • On-field labels use short codes such as GK, CB, CM, RW, ST
  • Roster cards use long translated labels
  • The current default locale for long labels is es-pe
  • PositionLabels is exported if your app wants to use the same mappings directly
  • PlayersSidebar and RosterPlayerCard support a locale parameter when used directly

Persistence #

The Player model is JSON-ready:

final json = players.map((p) => p.toJson()).toList();
final restored = jsonList.map((e) => Player.fromJson(e)).toList();

This makes it easy to store board state in local storage, shared preferences, a database, or an API.

Exported API #

The package exports:

  • Models: Player, enums, tactical zone types
  • Utils: CoordinateConverter, FormationHelper, PositionDetector, PositionLabels
  • Widgets: SoccerBoardWrapper, SoccerBoard, PlayersSidebar, SoccerBoardPlayer, FieldHalf, FieldLines

Example App #

See the example/ app in this repository for a full working integration, including:

  • state updates after dragging
  • persistence
  • player removal
  • formation labels
  • portrait and landscape switching

License #

MIT. See LICENSE.

0
likes
140
points
35
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter widget for a tactical soccer/football board with drag-and-drop player positioning, tactical zones, field orientation (portrait/landscape), and read-only mode. Perfect for lineup and formation editors.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on fuzo_soccer_board