File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed
Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import 'package:flutter_local_db/flutter_local_db.dart';
33
44void main () async {
55 WidgetsFlutterBinding .ensureInitialized ();
6- await LocalDB .init (localDbName : 'example_local_db' );
6+ await LocalDB .init ();
77 runApp (const ExampleApp ());
88}
99
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class LocalDbBridge extends LocalSbRequestImpl {
117117 log ('Using app directory: ${appDir .path }' );
118118
119119 /// Initialize database with default route and database name.
120- // Remove .db extension since Rust will add .lmdb
120+ // Ensure database name doesn't have extension, Rust expects .lmdb
121121 final dbBaseName = databaseName.replaceAll ('.db' , '' );
122122 await _init ('${appDir .path }/$dbBaseName ' );
123123
@@ -237,10 +237,11 @@ class LocalDbBridge extends LocalSbRequestImpl {
237237
238238 Future <void > _init (String dbName) async {
239239 try {
240- log ('Attempting to create database with path: $dbName ' );
241-
242240 // Rust expects the path to end with .lmdb
243241 final lmdbPath = '$dbName .lmdb' ;
242+ log ('Attempting to create database with base path: $dbName ' );
243+ log ('Full LMDB path: $lmdbPath ' );
244+
244245 final dbNamePointer = lmdbPath.toNativeUtf8 ();
245246 _dbInstance = _createDatabase (dbNamePointer);
246247
Original file line number Diff line number Diff line change @@ -15,16 +15,14 @@ import 'model/local_db_request_model.dart';
1515/// Uses a bridge pattern to abstract database interactions and provides
1616/// type-safe results using [LocalDbResult] .
1717class LocalDB {
18- /// Initializes the local database with a specified name.
18+ /// Initializes the local database with a standard name.
1919 ///
2020 /// This method must be called before performing any database operations.
21- ///
22- /// Parameters:
23- /// - [localDbName] : A unique name for the local database instance
21+ /// Uses a standard database name to avoid user errors and simplify the API.
2422 ///
2523 /// Throws an exception if initialization fails
26- static Future <void > init ({ required String localDbName} ) async {
27- await LocalDbBridge .instance.initialize (localDbName );
24+ static Future <void > init () async {
25+ await LocalDbBridge .instance.initialize ('flutter_local_db' );
2826 }
2927
3028 /// Avoid to use on production.
You can’t perform that action at this time.
0 commit comments