Closed simc closed 2 days ago
Hi @leisim thank you for your contribution (hive is the best)
@goderbauer Is this more work than just "flipping a switch"? Is there something I can help with?
@iapicca Anything I can help with?
The same problem, how can I solve it? Using 1.13.6-pre.44
@iapicca, I cannot agree with severe: new feature or proposal flag in this issue, it seems to be an error.
This singleline .dart file in project:
import 'dart:indexed_db';
With this pubspec.yaml is everything OK:
name: test
environment:
sdk: ^2.6.0
dependencies:
dev_dependencies:
test:
This pubspec.yaml shows error:
name: test
environment:
sdk: ^2.6.0
dependencies:
flutter:
sdk: flutter
dev_dependencies:
test:
Error:
Target of URI doesn't exist: 'dart:indexed_db'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.dart(uri_does_not_exist)
Any news @iapicca? It is blocking error for me. Is any chance for fixing this or is it possible to estimate time for solution?
Try pls this:
flutter create test_app
test_app
folder in vs codeimport 'dart:indexeddb';
into the first line (there is no problem to import other files, e.g. import 'dart:html';
)Thanks a lot for help.
Is there a reason indexed_db
is blocked on Flutter in the first place?
I'm trying to get some internal DB working for my Flutter app and with the mess of plugins I just want to do conditional imports and be done with it, but that seems to not be an option.
I had the same problem, right? Does anybody know how to do that?
I personally use package:idb_shim
.
It has an API that pretty much exactly matches the indexed_db api, but has implementations for every platform. All you need to do is provide it with a different IdbFactory
depending on the platform.
On mobile:
import "package:idb_shim/idb_shim.dart";
import "package:idb_shim/idb_io.dart";
import "package:path_provider/path_provider.dart";
/// Provides access to an IndexedDB implementation.
///
/// The mobile implementation is based on a .json file.
Future<IdbFactory> get idbFactory async => getIdbFactoryPersistent(
(await getApplicationDocumentsDirectory()).path
);
On web:
import "package:idb_shim/idb_shim.dart";
import "package:idb_shim/idb_browser.dart";
/// Provides access to an IndexedDB implementation.
///
/// The browser has an implementation built-in.
Future<IdbFactory> get idbFactory async => idbFactoryBrowser;
To coordinate it all, simply include these lines to import the correct IdbFactory
:
import "idb_factory_stub.dart"
if (dart.library.io) "idb_factory_io.dart"
if (dart.library.html) "idb_factory_web.dart";
Future<Database> getDatabase async => (await idbFactory).open(/* initialization logic here */);
This approach does work once set up and, with a mobile implementation as well, may be simpler than a native indexed_db
.
ref: https://www.gitmemory.com/issue/flutter/flutter/44937/570559644
According to what is said above, the reason has been found.
Isn't that just a link to the above comment? It just says the indexed_bd
is blocked on Flutter, but not why, or if it can be put back.
+1. Still hoping to use indexed_db in Flutter Web apps.
Is there a specific reason this isn't supported? Is this as simple as adding dart:indexed_db
to the copy of the Dart SDK used for analysis as was done in https://github.com/flutter/engine/pull/12435 for dart:html
, dart:js
, & dart:js_util
? If so, are you open to contributions?
CC: @devoncarew
Still waiting for this lol
Adding a comment here because since web browser supports this, all other platforms can easily support. Please provide a solution, since adding more and more packages makes the app grow in complexity. Using standard core libraries should be preferred.
indexed_db was only ever available in flutter_web applications, it does not work in flutter as we did not ship an indexed_db implementation in the engine. We have no plans to do so in the future.
The dart analyzer fails with the following message when I try to import
dart:indexed_db
:The package compiles without errors and can use the
dart:indexed_db
library just fine but the error message from the analyzer (and possible pana penalty) is still a problem.Steps to Reproduce
import
dart:indexed_db
in a flutter app or packageflutter doctor -v