flutter_js icon indicating copy to clipboard operation
flutter_js copied to clipboard

Result discrepancy using RRule.js library on Android vs iOS

Open SApolinario opened this issue 2 years ago • 1 comments

Hi I quickly threw together a test to see if I could make use of the RRule.js library to process calendar event recurrence rules. The snippet below should return an array of strings representing UTC dates. However instead I get [{}, {}, {}, {}...] on Android and a comma separated list of dates on iOS. Am I missing a step in regards to parsing the actual result? Great library BTW =)

`JavascriptRuntime flutterJs = getJavascriptRuntime();

String ajvJS = await rootBundle.loadString("assets/js/rrule.min.js");
flutterJs.evaluate("""var window = global = globalThis;""");
flutterJs.evaluate(ajvJS + "");

var rruleIsLoaded = flutterJs
    .evaluate("""var rruleIsLoaded = (typeof rrule == 'undefined') ? 
      "0" : "1"; rruleIsLoaded;
    """).stringResult;
print("RRule is Loaded $rruleIsLoaded");

var expression = """const rule = rrule.rrulestr('DTSTART:20120201T093000Z\\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20130130T230000Z;BYDAY=MO,FR')""";
flutterJs.evaluate(expression);

JsEvalResult result = flutterJs.evaluate("""rule.between(new Date(Date.UTC(2012, 1, 1)), new Date(Date.UTC(2013, 1, 1)))""");

print(result);`

SApolinario avatar May 26 '22 19:05 SApolinario

I got it working. I switched to using JavascriptCore on Android and I also JSON.stringify the result before passing it back to dart.

SApolinario avatar May 26 '22 21:05 SApolinario

I got it working

Can this be closed then?

shilangyu avatar Nov 05 '22 17:11 shilangyu

Yes, it can be closed. Sorry.

SApolinario avatar Nov 09 '22 13:11 SApolinario