Dart using jQuery date picker with initial parameters

Issue

This works:

js.context.callMethod(r'$', ['.datepicker']).callMethod('datepicker', []);

as in it shows a box with a calendar in it in the default form of mm/dd/yyyy but this doesn’t change the format:

js.context.callMethod(r'$', ['.datepicker']).callMethod('datepicker', [{'dateFormat':'dd-mm-yy'}]);

It works as above but still mm/dd/yyyy. What have I missed here?

Solution

When you use List or Map as parameter you have to use new JsObject.jsify.

For your case:

js.context.callMethod(r'$', ['.datepicker'])
    .callMethod('datepicker', [new JsObject.jsify({'dateFormat':'dd-mm-yy'})]);

Answered By – Alexandre Ardhuin

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *