Reflectable Error doing a simple DB Query on Flutter Web

Problem:
I am working on a flutter web application. I am able to contact my Backendless database and create tables with data without any problem, , but when I try to do a simple query, the application throws a reflectable error.

Question:
I imported the Reflectable library, but I don’t know what I need to do, or why this error is happening on query but not on create. Any help would be greatly appreciated. Dealing with reflectable is a real blocker for me. Is there a way that I can avoid needing to do this just to query or update a table?

Code:

await Backendless.initApp(

    applicationId: 'xxxxx',

    jsApiKey: 'xxxxx');

DataQueryBuilder queryBuilder = DataQueryBuilder()

  ..whereClause = "title LIKE '$keyword%'";

await Backendless.data

    .withClass<CustomClass>()

    .find(queryBuilder)

    .then((results) =>results);

Errror:
Error: Unhandled error Bad state: Reflectable has not been initialized.
Please make sure that the first action taken by your program
in main is to call initializeReflectable(). occurred in Instance of ‘SearchBloc’.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw
packages/reflectable/src/reflectable_builder_based.dart 180:5 get data
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 825:8 get
packages/reflectable/src/reflectable_builder_based.dart 2569:31 reflectType
packages/backendless_sdk/src/modules/data/reflector.dart 146:48 getServerName
packages/backendless_sdk/src/modules/data/data_store.dart 205:28 new
packages/backendless_sdk/src/modules/data/data.dart 35:39 withClass
packages/just_unsubbed/data/repositories/database_repository.dart 21:10 searchCreatorChannelByKeyword
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1613:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 155:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 707:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 736:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 542:5 [_completeWithValue]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 580:7 callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15

at Object.throw_ [as throw] (http://localhost:59376/dart_sdk.js:5041:11)
at http://localhost:59376/packages/bloc/src/bloc_observer.dart.lib.js:157:21
at search_bloc.SearchBloc.new.onError (http://localhost:59376/packages/bloc/src/bloc_observer.dart.lib.js:158:28)
at _RootZone.runBinaryGuarded (http://localhost:59376/dart_sdk.js:37227:11)
at sendError (http://localhost:59376/dart_sdk.js:31159:26)
at _BroadcastSubscription.new.[_sendError] (http://localhost:59376/dart_sdk.js:31176:11)
at _BroadcastSubscription.new.[_addError] (http://localhost:59376/dart_sdk.js:31102:27)
at http://localhost:59376/dart_sdk.js:31802:34
at _SyncBroadcastStreamController.new.[_forEachListener] (http://localhost:59376/dart_sdk.js:31652:13)
at _SyncBroadcastStreamController.new.[_sendError] (http://localhost:59376/dart_sdk.js:31801:31)
at _SyncBroadcastStreamController.new.[_addError] (http://localhost:59376/dart_sdk.js:31630:25)
at _RootZone.runBinaryGuarded (http://localhost:59376/dart_sdk.js:37227:11)
at sendError (http://localhost:59376/dart_sdk.js:31159:26)
at _ForwardingStreamSubscription.new.[_sendError] (http://localhost:59376/dart_sdk.js:31176:11)
at _ForwardingStreamSubscription.new.[_addError] (http://localhost:59376/dart_sdk.js:31102:27)
at _ForwardingStreamSubscription.new.[_addError] (http://localhost:59376/dart_sdk.js:35161:25)
at _MapStream.new.[_handleError] (http://localhost:59376/dart_sdk.js:35119:24)
at _ForwardingStreamSubscription.new.[_handleError] (http://localhost:59376/dart_sdk.js:35186:38)
at _RootZone.runBinaryGuarded (http://localhost:59376/dart_sdk.js:37227:11)
at sendError (http://localhost:59376/dart_sdk.js:31159:26)
at _ControllerSubscription.new.[_sendError] (http://localhost:59376/dart_sdk.js:31176:11)
at async._DelayedError.new.perform (http://localhost:59376/dart_sdk.js:34444:27)
at _StreamImplEvents.new.handleNext (http://localhost:59376/dart_sdk.js:34521:15)
at async._AsyncCallbackEntry.new.callback (http://localhost:59376/dart_sdk.js:34282:16)
at Object._microtaskLoop (http://localhost:59376/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:59376/dart_sdk.js:37532:13)
at http://localhost:59376/dart_sdk.js:33303:9

Hi, @Carlton_Branch

This support topic can help you to solve the issue, if not please provide us with the version of Flutter SDK you are using?

Regards,
Marina

Hi Marina,
Thank-you for replying so quickly.
Yes, I had read this post. It doesn’t seem to be my issue.
I am using:
backendless_sdk: ^7.1.1
Flutter 2.5.0 • channel stable

Any help would be greatly appreciated. I don’t understand why I would have no trouble adding tables and records, but be unable to query the same database.

@Carlton_Branch, I have created an internal ticket - BKNDLSS-26271, our Flutter developer will investigate your case, as soon as we have any solution of it we will write you.

Regards,
Marina

Thank-you, Marina.
Please note that this is Flutter Web not mobile.
There may be some specific adjustment that I need to make to support the web application. Also, I am willing to try any workaround options.

This is the error from bloc.dart

I switched my code to avoid using Custom Classes, since that requires Reflectable:

Screenshot_4

Now I get a PlatformException:

Error: Unhandled error PlatformException(error, Expected a value of type ‘(dynamic) => dynamic’, but got one of type ‘(Object) => Object’, null, null) occurred in Instance of ‘SearchBloc’.

Neither of the standard methods of doing queries seem to be working in this project.

Hi @Carlton_Branch

Did you follow the steps described in this article?

Make sure you

call the initializeReflectable() method in your main method.

and

run the following command:

flutter packages pub run build_runner build

Best Regards,
Maksym

Thanks for the info.
Hopefully it helps someone else with this problem.
I have gone with a different BaaS platform and replaced all the backendless code in my app so you can consider this issue closed.

May I ask, what was the reason of your decision? Missing functionality, difficulty or something else?