Building a puzzle game with Flutter and Riverpod

A look at how Arrow Puzzle is organised: logic kept apart from the UI, custom painters for the snakes, and a small, testable core.

Arrow Puzzle is built with Flutter, which lets us ship one codebase to Android, iOS and the web. Here is how we structured it, and the rules we set ourselves to keep it maintainable as a small studio.

Logic and UI never mix

The single most useful rule: game logic does not live in widgets, and UI does not live in game logic. The project is split into folders with clear jobs:

  • models hold plain data types such as the direction, cell, piece, board and level
  • game_logic holds the movement engine, the win and star calculation, and the level validator
  • data loads levels from bundled JSON files and stores progress locally
  • presentation holds the screens, widgets and controllers
  • services wrap ads, audio and in-app purchases

There is no backend. Levels ship as JSON files inside the app, and progress is saved on the device.

State with Riverpod

We use Riverpod for state management. The board, the current session and the player's progress are each exposed as a provider, which keeps screens thin: they watch state and send taps to a controller instead of making decisions themselves.

Draw pieces as paths, not boxes

A snake looks wrong if it is drawn as a row of separate squares. Each piece is painted with a custom painter as one continuous rounded path, with round joins at the corners and an arrowhead triangle on the head. A soft shadow lifts it off the board. The cell size is calculated from the screen so the grid fits phones of all sizes.

Validate first, animate second

When you tap a piece, the code first runs the movement simulation to learn the outcome. Only then does it start an animation. That means the visuals are always showing a result that has already been decided, and the board state is never left half-changed if an animation is interrupted.

Small habits that paid off

  • Use named types for cell positions instead of bare number pairs
  • Always step through a direction helper rather than adding offsets by hand
  • Use constant constructors wherever possible
  • Dispose every animation controller and subscription
  • Unit-test the movement engine for exits, bounces and edge cases like a piece at the boundary or blocked on its first step

One platform wrinkle

Ads differ between mobile and web, so the ad service is an interface with separate implementations, chosen at startup with a simple platform check. Swapping to an ad-free version after a purchase uses the same interface.

Takeaway

For a solo or tiny team, structure is what lets you move fast later. A strict separation between rules and rendering made this game easy to test and easy to change.

More from the Arrow Puzzle devlog

All posts
17 November 2026How we make sure every Arrow Puzzle level can be solvedA puzzle that cannot be solved is a bug. Here is how Arrow Puzzle generates dense, winding levels and verifies each one before it ships.15 November 2026A logo drawn in code, and a Home screen to matchArrow Puzzle's logo is not an image file. It is four game pieces and a wordmark painted by the same code that draws the board.15 November 2026Shipping web updates without asking players to clear their cacheWe moved Arrow Puzzle to Cloudflare Workers, then fixed a stubborn problem: returning visitors seeing an old build after every deploy.