Installation
This page will guide you through the process of installing and configuring QuantumCacheDB in your Dart or Flutter project.
Prerequisites
Before you begin, ensure that you have the following installed on your machine:
- Flutter (for Flutter projects) or Dart SDK (for Dart projects).
- A text editor or IDE such as VS Code or Android Studio.
- QuantumCacheDB is compatible with Flutter, Dart, and any local data storage requirements.
Step 1: Add Dependency
To get started, you'll need to add QuantumCacheDB as a dependency to your pubspec.yaml file.
For Flutter Projects:
In your Flutter project, open the pubspec.yaml file and add quantum_cache_db under dependencies:
dependencies:
quantum_cache_db: ^1.0.0
After saving the pubspec.yaml file, run the following command in your terminal to fetch the package:
flutter pub get
For Dart Projects:
For Dart-only projects, open the pubspec.yaml file and add the package similarly:
dependencies:
quantum_cache_db: ^1.0.0
Then, run:
pub get
Step 2: Initialize QuantumCacheDB
Now that you have installed the package, you need to initialize QuantumCacheDB in your Dart or Flutter application.
Example: Dart Project
In your Dart main.dart file (or the entry point of your Dart application), initialize QuantumCacheDB as follows:
import 'package:quantum_cache_db/quantum_cache_db.dart';
void main() {
final db = QuantumCacheDB();
// Initialize the database and start using it
db.init();
}
Example: Flutter Project
In a Flutter project, initialize QuantumCacheDB in your main.dart file:
import 'package:flutter/material.dart';
import 'package:quantum_cache_db/quantum_cache_db.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('QuantumCacheDB Example')),
body: Center(
child: ElevatedButton(
onPressed: () {
final db = QuantumCacheDB();
db.init();
},
child: Text('Initialize QuantumCacheDB'),
),
),
),
);
}
}
This initializes the database and makes it ready to store and manage data locally.
Step 3: Verify Installation
To verify that the package was successfully installed and initialized, you can run your app (either Flutter or Dart) and check the console output. If QuantumCacheDB was initialized correctly, there should be no errors, and your app should be able to interact with the database seamlessly.
Troubleshooting
If you encounter any issues during installation or initialization, make sure you:
- Have the correct version of Flutter or Dart SDK installed.
- Have correctly added the dependency in
pubspec.yamland runflutter pub getorpub get. - Have properly initialized QuantumCacheDB in your main entry file (e.g.,
main.dart).
If problems persist, visit the QuantumCacheDB GitHub for issues and troubleshooting.
Conclusion
Now that you’ve installed QuantumCacheDB, you're ready to start using it in your Dart or Flutter projects. This guide covered the installation process. Next, explore how to perform CRUD operations and more in the following documentation sections.