Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting.
No setup needed, script tags are injected at plugin initialization time (using code from mobile scanner plugin).
The code is a straightforward porting of the Kotlin plugin code.
I'm not very well versed in JS interop, and I couldn't find a way to correctly build the Intl.DisplayNames object used to fill in the country name in getAllSupportedRegions().
I tried declaring a constructor for DisplayNames on the dart side but it would fail with a weird error
missing "type" option in DisplayNames()
even though I was passing it. I tried with both a simple Map or a JsObject as parameter, with no luck.
Having failed at that, I resorted to declaring a factory function libPhoneNumberFlutterGetRegionDisplayNames() in javascript.
I'm using this in our company's app - it works fine, but for some reason there seems to be a problem with loading the library on the example app, so I marked it as draft.
Please note the code taken from mobile scanner is BSD-3 licensed. I included the copyright notice in the relevant files.
Web implementation for libphonenumber.
Uses google-libphonenumber from jsdelivr https://www.jsdelivr.com/package/npm/google-libphonenumber
No setup needed, script tags are injected at plugin initialization time (using code from mobile scanner plugin).
The code is a straightforward porting of the Kotlin plugin code. I'm not very well versed in JS interop, and I couldn't find a way to correctly build the
Intl.DisplayNames
object used to fill in the country name ingetAllSupportedRegions()
. I tried declaring a constructor forDisplayNames
on the dart side but it would fail with a weird erroreven though I was passing it. I tried with both a simple
Map
or aJsObject
as parameter, with no luck.Having failed at that, I resorted to declaring a factory function
libPhoneNumberFlutterGetRegionDisplayNames()
in javascript.I'm using this in our company's app - it works fine, but for some reason there seems to be a problem with loading the library on the example app, so I marked it as draft.
Please note the code taken from mobile scanner is BSD-3 licensed. I included the copyright notice in the relevant files.