flutter_local_db 0.0.2 copy "flutter_local_db: ^0.0.2" to clipboard
flutter_local_db: ^0.0.2 copied to clipboard

A scalable and easy-to-use NoSQL database

Flutter Local DB #

A high-performance local database for Flutter that provides incredible simplicity with powerful underlying architecture. Store any JSON data with just an ID string and let the system handle all the complexity for you.

Why Flutter Local DB? #

  • 🎯 Ultimate Simplicity: Store any JSON with just an ID
  • Lightning Fast: O(1) access times through smart indexing
  • 🛡️ Fault Tolerant: Corrupted file? No problem, only affects that block
  • 📦 Infinitely Scalable: No practical size limits thanks to block architecture
  • 🔍 Smart Storage: Automatic block management and space optimization
  • 🚀 Zero Config: Just initialize and start using

Installation #

dependencies:
  flutter_local_db: ^0.0.2
copied to clipboard

Quick Start #

1. Initialize #

void main() async {
  await LocalDB.init();
  runApp(MyApp());
}
copied to clipboard

2. Store Data #

// Store any JSON data with just an ID
await LocalDB.Post('user_123', {
  'name': 'John Doe',
  'age': 30,
  'preferences': {
    'theme': 'dark',
    'notifications': true
  },
  'scores': [100, 95, 98]
});
copied to clipboard

3. Retrieve Data #

// Get by ID - Lightning fast O(1) operation
final userData = await LocalDB.GetById('user_123');

// Get multiple records with pagination
final records = await LocalDB.Get(limit: 20, offset: 0);
copied to clipboard

4. Update Data #

// Simply provide the ID and updated data
await LocalDB.Put('user_123', {
  'name': 'John Doe',
  'age': 31,  // Updated age
  'preferences': {
    'theme': 'light'  // Changed theme
  }
});
copied to clipboard

5. Delete Data #

// Delete single record
await LocalDB.Delete('user_123');

// Clear database
await LocalDB.Clean();
copied to clipboard

Why It's Amazing #

🎯 Built for Simplicity #

Store any JSON structure you want - the system handles all the complexity:

// Store simple data
await LocalDB.Post('settings', {'theme': 'dark'});

// Store complex nested structures
await LocalDB.Post('gameState', {
  'player': {
    'position': {'x': 100, 'y': 200},
    'inventory': ['sword', 'shield'],
    'stats': {
      'health': 100,
      'mana': 50,
      'skills': ['jump', 'run']
    }
  }
});
copied to clipboard

⚡ Smart Architecture #

local_database/
├── active/          # Active data
    ├── ab/         # Smart hash prefixing
        ├── index   # Fast lookup index
        └── block   # Isolated data block
    └── cd/         # Another prefix
└── backup/         # Automatic backups
copied to clipboard

🛡️ Fault Tolerance #

  • Each record is stored in isolated blocks
  • If one file corrupts, other data remains safe
  • Automatic block management and optimization

🚀 High Performance #

  • O(1) access time for any record
  • Smart caching system
  • Efficient space management
  • Distributed block structure

Real World Example #

class GameSaveSystem {
  // Save game state
  Future<void> saveGame(String saveId, Map<String, dynamic> gameState) async {
    await LocalDB.Post(saveId, gameState);
  }

  // Load game state
  Future<Map<String, dynamic>> loadGame(String saveId) async {
    return await LocalDB.GetById(saveId);
  }

  // Update specific game data
  Future<void> updateGameState(String saveId, Map<String, dynamic> newState) async {
    await LocalDB.Put(saveId, newState);
  }
}
copied to clipboard

Benefits at Scale #

  • Infinite Scalability: No practical size limits thanks to block-based architecture
  • Fast Regardless of Size: O(1) access time whether you have 10 or 10 million records
  • Space Efficient: Smart block management and automatic optimization
  • Data Safety: Corruption in one file never affects other data
  • Memory Efficient: Loads only what you need, when you need it

Perfect for:

  • Game save systems
  • User preferences
  • Cached API responses
  • Offline data storage
  • And much more!

Contributing #

Contributions are welcome! If you find a bug or want a feature, please file an issue. Feel free to make a pull request if you want to contribute code.

Testing #

flutter test
copied to clipboard

Example #

A complete example can be found in the /example directory.

Contribution #

Contributions are welcome! If you have ideas for new features or improvements, please open an issue or submit a pull request.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a pull request.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Author #

Made with ❤️ by JhonaCode

10
likes
0
points
74
downloads

Publisher

verified publisherjhonacode.com

Weekly Downloads

2024.10.07 - 2025.04.21

A scalable and easy-to-use NoSQL database

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, flutter, path, path_provider, reactive_notifier, web

More

Packages that depend on flutter_local_db