-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(neon_framework): migrate to neon_storage #2529
base: main
Are you sure you want to change the base?
Changes from all commits
be5fb0d
e3de7c9
b28dae6
fef7677
b7d8a42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does it work without the platform specific initialization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The neon_storage package handles this with a conditional import/export. neon/packages/neon_framework/packages/neon_storage/lib/src/sqlite/sqlite.dart Lines 1 to 3 in 5484049
We can not easily run the neon_storage tests on web but I'll verify again that this actually works. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:neon_storage/neon_sqlite.dart'; | ||
import 'package:neon_storage/neon_storage.dart'; | ||
|
||
import 'package:path_provider/path_provider.dart'; | ||
|
||
/// Database holding the neon cache. | ||
final class NeonCacheDB extends MultiTableDatabase { | ||
/// Creates a new database with the given [tables]. | ||
factory NeonCacheDB({ | ||
Iterable<Table>? tables, | ||
}) { | ||
return NeonCacheDB._( | ||
tables: [ | ||
...?tables, | ||
if (!kIsWeb) SQLiteRequestCache.table, | ||
if (!kIsWeb) SQLiteCookiePersistence.table, | ||
], | ||
); | ||
} | ||
|
||
NeonCacheDB._({ | ||
required super.tables, | ||
}); | ||
|
||
@override | ||
String get name => 'cache'; | ||
|
||
@override | ||
Future<String> get path async { | ||
final cacheDir = await getApplicationCacheDirectory(); | ||
|
||
return buildDatabasePath(cacheDir.path, name); | ||
} | ||
|
||
/// The current request cache if available. | ||
RequestCache? get requestCache { | ||
if (kIsWeb) { | ||
return null; | ||
} | ||
|
||
assertInitialized(); | ||
|
||
return const SQLiteRequestCache(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:neon_storage/neon_sqlite.dart'; | ||
import 'package:neon_storage/neon_storage.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
/// Database holding the neon data. | ||
final class NeonDataDB extends MultiTableDatabase { | ||
/// Creates a new database with the given [tables]. | ||
factory NeonDataDB({ | ||
Iterable<Table>? tables, | ||
}) { | ||
return NeonDataDB._( | ||
tables: [ | ||
...?tables, | ||
SQLiteCachedPersistence.table, | ||
], | ||
); | ||
} | ||
|
||
NeonDataDB._({ | ||
required super.tables, | ||
}); | ||
|
||
@override | ||
String get name => 'preferences'; | ||
|
||
@override | ||
Future<String> get path async { | ||
final cacheDir = await getApplicationSupportDirectory(); | ||
|
||
return buildDatabasePath(cacheDir.path, name); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export 'package:neon_framework/src/storage/neon_cache_db.dart'; | ||
export 'package:neon_framework/src/storage/neon_data_db.dart'; | ||
export 'package:neon_framework/src/storage/settings_store.dart'; | ||
export 'package:neon_framework/src/storage/single_value_store.dart'; | ||
export 'package:neon_framework/src/storage/storage_keys.dart'; | ||
export 'package:neon_framework/src/storage/storage_manager.dart'; | ||
export 'package:neon_framework/storage.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still required for Android/iOS