Skip to content

Commit e247050

Browse files
committed
F**
1 parent 4241175 commit e247050

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

example/example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter_local_db/flutter_local_db.dart';
33

44
void main() async {
55
WidgetsFlutterBinding.ensureInitialized();
6-
await LocalDB.init(localDbName: 'example_local_db');
6+
await LocalDB.init();
77
runApp(const ExampleApp());
88
}
99

lib/src/bridge/local_db_bridge.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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

lib/src/local_db.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff 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].
1717
class 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.

0 commit comments

Comments
 (0)