puzzle_game 1.0.0
puzzle_game: ^1.0.0 copied to clipboard
description: A Flutter package for creating interactive puzzle games with rewards and customizable storage options.
Puzzle Reward Package #
A Flutter package that allows developers to integrate interactive puzzle games into their applications. Users solve puzzles to unlock rewards, with customizable UI, storage options, and animations.
⨠Features #
- đŽ Interactive drag-and-drop 4x4 puzzle game
- đ Reward unlocking with Lottie animations and images
- đ Multiple storage options:
- SharedPreferences
- REST API (Basic / JWT)
- Firebase Firestore
- đ¨ Customizable colors, texts, and puzzle piece shapes
- ⥠Smooth animations for reveal, drag, drop, and unlock screens
- đĻ Modular structure with controllers, models, and utils
đĻ Installation #
Add the following to your pubspec.yaml:
dependencies:
puzzle_game:^1.0.0
Run:
flutter pub get
đ Usage #
Import the package #
import 'package:puzzle_game/puzzle_game.dart';
Example with SharedPreferences #
PuzzleGameScreen(
config: PuzzleConfig(
puzzleImages: [
'assets/images/puzzle_piece.png',
'assets/images/puzzle_piece-4.png',
'assets/images/puzzle_piece-8.png',
'assets/images/puzzle_piece-12.png',
'assets/images/puzzle_piece-1.png',
'assets/images/puzzle_piece-5.png',
'assets/images/puzzle_piece-9.png',
'assets/images/puzzle_piece-13.png',
'assets/images/puzzle_piece-2.png',
'assets/images/puzzle_piece-6.png',
'assets/images/puzzle_piece-10.png',
'assets/images/puzzle_piece-14.png',
'assets/images/puzzle_piece-3.png',
'assets/images/puzzle_piece-7.png',
'assets/images/puzzle_piece-11.png',
'assets/images/puzzle_piece-15.png',
],
lottieAnimationPath: 'assets/animations/SmjpT6YB5S.json',
rewardImage: 'assets/images/example.png',
congratsTitle: 'ā¤Ŧā¤§ā¤žā¤ ā¤šāĨ!',
congratsSubtitle: 'ā¤ā¤Ē⤍āĨ ā¤ā¤ puzzle piece unlock ā¤ā¤ŋā¤¯ā¤ž ā¤šāĨ!',
unlockButtonText: 'UNLOCK ā¤ā¤°āĨā¤',
primaryColor: Colors.green,
buttonColor: Colors.black,
storageType: StorageType.sharedPreferences,
onComplete: () {
print('Puzzle completed!');
},
onSkip: () {
print('Puzzle skipped!');
},
),
)
Example with REST API (Basic) #
PuzzleGameScreen(
config: PuzzleConfig(
puzzleImages: [...],
storageType: StorageType.basicApi,
getApiUrl: 'https://yourapi.com/puzzle-progress',
postApiUrl: 'https://yourapi.com/save-progress',
primaryColor: Colors.blue,
buttonColor: Colors.orange,
onComplete: () {
print('Puzzle completed with API storage!');
},
),
)
Example with REST API (JWT) #
PuzzleGameScreen(
config: PuzzleConfig(
puzzleImages: [...],
storageType: StorageType.jwtApi,
getApiUrl: 'https://yourapi.com/puzzle-progress',
postApiUrl: 'https://yourapi.com/save-progress',
jwtToken: 'YOUR_JWT_TOKEN',
primaryColor: Colors.red,
buttonColor: Colors.black,
),
)
Example with Firebase #
PuzzleGameScreen(
config: PuzzleConfig(
puzzleImages: [...],
storageType: StorageType.firebase,
userId: 'unique_user_id',
primaryColor: Colors.deepPurple,
buttonColor: Colors.amber,
onComplete: () {
print('Puzzle completed with Firebase storage!');
},
),
)
âī¸ Configuration Options #
PuzzleConfig #
- puzzleImages (List â 16 puzzle image paths (mandatory)
- lottieAnimationPath (String?) â Path to Lottie animation
- rewardImage (String?) â Path to reward image
- congratsTitle (String) â Title text after puzzle completion
- congratsSubtitle (String) â Subtitle text after completion
- unlockButtonText (String) â Text for unlock button
- primaryColor (Color) â Theme color for UI
- buttonColor (Color) â Unlock button color
- bulgeSize / bulgeDepth / bulgeStartFraction / bulgeEndFraction (double) â Customize puzzle piece shape
- storageType (StorageType) â Storage method (
sharedPreferences,basicApi,jwtApi,firebase) - getApiUrl / postApiUrl / deleteApiUrl (String?) â API endpoints for saving progress
- jwtToken (String?) â JWT token for API auth
- userId (String?) â Required for Firebase storage
- onComplete (Function?) â Callback when puzzle is completed
- onSkip (Function?) â Callback when skipped
đ Storage Options #
- SharedPreferences â Stores puzzle progress locally.
- Basic API â Requires
getApiUrlandpostApiUrl. - JWT API â Requires
getApiUrl,postApiUrl, andjwtToken. - Firebase â Requires
userIdand Firebase Firestore setup.
đ¸ Screenshots #
Locked Piece #

Unlocked Piece #

Puzzle Board #

Congrats Screen #

đ ī¸ Development #
Clone the repo and run example:
git clone https://github.com/HarshAshGangar/puzzle_game.git
cd puzzle_game
flutter run example
đ¤ Contributing #
Contributions are welcome! Please fork the repo and submit a PR.
đ License #
This project is licensed under the MIT License.
đ Changelog #
See CHANGELOG.md for details.