I created tables in web_sql(browser) ,i succeed to create tables and insert to them data by when i am trying to do query for selecting something it failed. What am trying to do it receive data from promise in js:
Doc: https://api.flutter.dev/flutter/dart-js_util/promiseToFuture.html But i am getting this error:
Error: Expected a value of type 'JsObject', but got one of type 'JavaScriptObject'
at Object.throw_ [as throw] (http://localhost:55897/dart_sdk.js:5061:11)
at Object.castError (http://localhost:55897/dart_sdk.js:5020:15)
at Object.cast [as as] (http://localhost:55897/dart_sdk.js:5345:17)
at Function.as_C [as as] (http://localhost:55897/dart_sdk.js:4966:19)
at sqflite_web_impl.SqfliteWebDatabase.new.rawQuery (http://localhost:55897/packages/sqflite_web/src/sqflite_web_impl.dart.lib.js:254:84)
at rawQuery.next (<anonymous>)
at http://localhost:55897/dart_sdk.js:38640:33
at _RootZone.runUnary (http://localhost:55897/dart_sdk.js:38511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:55897/dart_sdk.js:33713:29)
at handleValueCallback (http://localhost:55897/dart_sdk.js:34265:49)
at Function._propagateToListeners (http://localhost:55897/dart_sdk.js:34303:17)
at _Future.new.[_completeWithValue] (http://localhost:55897/dart_sdk.js:34151:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:55897/dart_sdk.js:34172:35)
at Object._microtaskLoop (http://localhost:55897/dart_sdk.js:38778:13)
at _startMicrotaskLoop (http://localhost:55897/dart_sdk.js:38784:13)
at http://localhost:55897/dart_sdk.js:34519:9
Here is my dart
code:
@JS('runParamsResult')
external js.JsObject _dbRunWithParamsResult(String sql, dynamic params);
@override
Future<List<Map<String, dynamic>>> rawQuery(String sql, [List? sqlArguments]) async {
js.JsObject result;
logSql(sql: sql, sqlArguments: sqlArguments);
if (sqlArguments?.isNotEmpty ?? false) {
try {
final data = await promiseToFuture(_dbRunWithParamsResult(sql, sqlArguments)); /*Failed here*/
... continue logic
Js code:
runParamsResult: function (sql, params) {
return new Promise((resolve, reject) => {
db.transaction(function (tx) {
tx.executeSql(sql, params, function (tx, results) {
console.log("show size:" + results.rows.length);
resolve(results.rows);
}, (sqlt, error) => reject(error));
});
});
},