Pricing changes are coming in January. Contact our Sales team to secure the current price for your desired license.

An exception raised while using getReport() api call in Flutter

Answered
kadri izer asked on July 13, 2024

Hello,

I am a single developer and I'm trying to develop some mobil app. I'm glad saw your product. And I started to use it for some tests for my app.

But i faced with some issues, while using getReport() api call. I just want to get current report object which I updated using toolbar.

Code is as following...

// _pivot is a variable which declared alreay as a Flexmonster

final report = _pivot.getReport();

 

Exception is ;

ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FormatException: Unexpected character (at line 2, character 5)
 

 
 

creationDate = "2024-07-13T13:03:40.295Z";

^

Thanks for advance 🙂

13 answers

Public
kadri izer July 13, 2024

Hello again,

Found some problem in flutter_flexmonster.dart.

///This API call returns report JSON object as string
Future<dynamic> getReport() async {
WebViewController apiController=await controller.future;
String reportString=await apiController.runJavascriptReturningResult("flexmonster.getReport()");
dynamic report=jsonDecode(reportString); // here : reportString is not a json string!!!
return report;
}

 

 

 

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 16, 2024

Hello,

Thank you for reaching out to us.

In our investigation, we were unable to replicate this specific error. However, a similar error was observed in the stack trace when we intentionally set the report as an invalid JSON object.
Please note that the string in the stack trace does not adhere to valid JSON syntax. You mentioned updating the report via the Toolbar; we suppose that the invalid report could have been passed by loading a custom report. To see if this is the case, we recommend testing getReport after loading our sample report through the "Report" tab: https://cdn.flexmonster.com/reports/report.json
For more information, refer to our integration guide with Flutter or check code examples in our GitHub sample project.

We are looking forward to hearing from you.

Best Regards,
Maksym

Public
kadri izer July 17, 2024

I will prepare a sample project for you, you to reproduce issue. But I am quite busy. Once I have done, I will inform you again 🙂

Thanks for answer,

Kadri.

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 17, 2024

Hello, Kadri!

Thank you for your reply.
Please take any time necessary to prepare the sample project and let us know when it is ready. Our team will be here to help you in finding a solution.
We are looking forward to hearing from you.

Best Regards,
Maksym

Public
kadri izer July 21, 2024

I changed my macbook and setup from scratch. So i do not have any problem anymore. 

I am sorry, because it was my mistake 🙂

 

Regards,

Kadri.

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 22, 2024

Hi, Kadri!

Thank you for sharing these updates.
We are glad to hear that you could resolve this issue on your side.
Please let us know if any other questions arise.

Best Regards,
Maksym

Public
kadri izer July 24, 2024

Hello again,
I found out the real issue. It works on android simulator very well but not on ios simulator.

Can you please test it an inform me?

Thanks in advance.

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 26, 2024

Hello, Kadri!

Thank you for sharing this with us.

We could reproduce this behavior while testing on iOS. Our team will investigate this issue and provide a fix in one of the upcoming minor releases, ETA Aug 19th. As a possible workaround, you could directly call the getReport via JavaScript from WebViewController:

import 'package:webview_flutter/webview_flutter.dart';
//Other code
WebViewController controller = await pivot.controller.future;
String report = await controller.runJavascriptReturningResult('flexmonster.getReport()');

This code would return the report as a string. Even if the report is malformed, some information can still be retrieved.

Please let us know if this would work for you.

Best Regards,
Maksym

Public
kadri izer July 26, 2024

I solved this issue already by using the way almost same. Just I updated your code 😉 But that was not enough, so I converted the information to json 😉

Summary: I can wait until your update. But my license is trial and might not wait 😉

Whatever thanks a lot!

Public
Maksym Diachenko Maksym Diachenko Flexmonster July 29, 2024

Hello, Kadri!

Thank you for your reply.
We are glad to hear that you found a temporary workaround for an issue. Please stay tuned for our updates regarding the fix.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster August 21, 2024

Hello, Kadri,

We are glad to inform you that the issue when certain methods that return JSON were causing exceptions on iOS was fixed.
This is available in the 2.9.84 version of Flexmonster: https://www.flexmonster.com/release-notes/version-2-9-84/
You are welcome to update the component. Here is our guide on upgrading to the latest version: https://www.flexmonster.com/doc/updating-to-the-latest-version/

Please let us know if the fix works.

Best regards,
Maksym

Public
kadri izer August 21, 2024

Hello again 

Thank you for informing me about new version and fix. I tried new version already and ios is fixed but for android I had to use a tricky way, because it returns as string on android platform. But this is not a big problem. It can be solved by handling platforms.

 I just suggest for flutter version, you to use webvlew_flutter newest version instead 3.04.

 

I sent you updated file ...

Sincerely,

Kadri. 

Public
Maksym Diachenko Maksym Diachenko Flexmonster August 22, 2024

Hello, Kadri!

Thank you for confirming that the fix worked on your end.
We appreciate the suggestion regarding updating the webvlew_flutter library within the flutter_flexmonster. We will add this to our wishlist and include it in one of our future releases.
Please let us know if any other questions arise.

Best Regards,
Maksym

Please login or Register to Submit Answer