├── .gitignore ├── LICENSE ├── README.md ├── all_lint_rules.yaml ├── analysis_options.yaml ├── melos.yaml ├── packages ├── flutter_libphonenumber │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── .metadata │ │ ├── README.md │ │ ├── android │ │ │ ├── .gitignore │ │ │ ├── app │ │ │ │ ├── build.gradle │ │ │ │ └── src │ │ │ │ │ ├── debug │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ ├── main │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── kotlin │ │ │ │ │ │ └── com │ │ │ │ │ │ │ └── example │ │ │ │ │ │ │ └── flutter_libphonenumber_example │ │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ └── res │ │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ └── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── profile │ │ │ │ │ └── AndroidManifest.xml │ │ │ ├── build.gradle │ │ │ ├── gradle.properties │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ └── gradle-wrapper.properties │ │ │ └── settings.gradle │ │ ├── ios │ │ │ ├── .gitignore │ │ │ ├── Flutter │ │ │ │ ├── AppFrameworkInfo.plist │ │ │ │ ├── Debug.xcconfig │ │ │ │ └── Release.xcconfig │ │ │ ├── Podfile │ │ │ ├── Runner.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ ├── project.xcworkspace │ │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ │ └── xcshareddata │ │ │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ │ │ └── WorkspaceSettings.xcsettings │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── Runner.xcscheme │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ │ └── WorkspaceSettings.xcsettings │ │ │ └── Runner │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Assets.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ │ └── LaunchImage.imageset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── LaunchImage.png │ │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ │ └── README.md │ │ │ │ ├── Base.lproj │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ │ ├── Info.plist │ │ │ │ └── Runner-Bridging-Header.h │ │ ├── lib │ │ │ └── main.dart │ │ ├── pubspec.yaml │ │ └── web │ │ │ ├── favicon.png │ │ │ ├── icons │ │ │ ├── Icon-192.png │ │ │ ├── Icon-512.png │ │ │ ├── Icon-maskable-192.png │ │ │ └── Icon-maskable-512.png │ │ │ ├── index.html │ │ │ └── manifest.json │ ├── lib │ │ └── flutter_libphonenumber.dart │ └── pubspec.yaml ├── flutter_libphonenumber_android │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ ├── settings.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── kotlin │ │ │ └── com │ │ │ └── bottlepay │ │ │ └── flutter_libphonenumber │ │ │ └── FlutterLibphonenumberPlugin.kt │ ├── example │ │ ├── README.md │ │ ├── android │ │ │ ├── .gitignore │ │ │ ├── app │ │ │ │ ├── build.gradle │ │ │ │ └── src │ │ │ │ │ ├── debug │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ ├── main │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── kotlin │ │ │ │ │ │ └── com │ │ │ │ │ │ │ └── bottlepay │ │ │ │ │ │ │ └── flutter_libphonenumber_android_example │ │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ └── res │ │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ ├── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ └── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── profile │ │ │ │ │ └── AndroidManifest.xml │ │ │ ├── build.gradle │ │ │ ├── gradle.properties │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ └── gradle-wrapper.properties │ │ │ └── settings.gradle │ │ ├── lib │ │ │ └── main.dart │ │ └── pubspec.yaml │ ├── lib │ │ └── flutter_libphonenumber_android.dart │ └── pubspec.yaml ├── flutter_libphonenumber_ios │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── README.md │ │ ├── ios │ │ │ ├── .gitignore │ │ │ ├── Flutter │ │ │ │ ├── AppFrameworkInfo.plist │ │ │ │ ├── Debug.xcconfig │ │ │ │ └── Release.xcconfig │ │ │ ├── Podfile │ │ │ ├── Runner.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ ├── project.xcworkspace │ │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ │ └── xcshareddata │ │ │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ │ │ └── WorkspaceSettings.xcsettings │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── Runner.xcscheme │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ │ └── WorkspaceSettings.xcsettings │ │ │ └── Runner │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Assets.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ │ └── LaunchImage.imageset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── LaunchImage.png │ │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ │ └── README.md │ │ │ │ ├── Base.lproj │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── Main.storyboard │ │ │ │ ├── Info.plist │ │ │ │ └── Runner-Bridging-Header.h │ │ ├── lib │ │ │ └── main.dart │ │ └── pubspec.yaml │ ├── ios │ │ ├── .gitignore │ │ ├── Assets │ │ │ └── .gitkeep │ │ ├── Classes │ │ │ ├── FlutterLibphonenumberPlugin.h │ │ │ ├── FlutterLibphonenumberPlugin.m │ │ │ └── SwiftFlutterLibphonenumberIosPlugin.swift │ │ ├── Resources │ │ │ └── PrivacyInfo.xcprivacy │ │ └── flutter_libphonenumber_ios.podspec │ ├── lib │ │ └── flutter_libphonenumber_ios.dart │ └── pubspec.yaml ├── flutter_libphonenumber_platform_interface │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── flutter_libphonenumber_platform_interface.dart │ │ └── src │ │ │ ├── method_channel │ │ │ └── flutter_libphonenumber_method_channel.dart │ │ │ ├── platform_interface │ │ │ └── flutter_libphonenumber_platform.dart │ │ │ └── types │ │ │ ├── country_manager.dart │ │ │ ├── country_with_phone_code.dart │ │ │ ├── format_phone_result.dart │ │ │ ├── input_formatter.dart │ │ │ ├── phone_mask.dart │ │ │ ├── phone_number_format.dart │ │ │ └── phone_number_type.dart │ ├── pubspec.yaml │ └── test │ │ ├── flutter_libphonenumber_test.dart │ │ └── input_formatter_test.dart └── flutter_libphonenumber_web │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ ├── README.md │ ├── lib │ │ └── main.dart │ ├── pubspec.yaml │ └── web │ │ ├── favicon.png │ │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ │ ├── index.html │ │ └── manifest.json │ ├── lib │ ├── flutter_libphonenumber_web.dart │ └── src │ │ ├── base.dart │ │ ├── libphonenumber.dart │ │ └── utils.dart │ └── pubspec.yaml └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .atom/ 3 | .idea 4 | .packages 5 | .pub/ 6 | .dart_tool/ 7 | .vscode/ 8 | *.iml 9 | 10 | # Gradle? 11 | .uuid 12 | 13 | pubspec.lock 14 | 15 | Podfile.lock 16 | Pods/ 17 | .symlinks/ 18 | 19 | *instrumentscli*.trace 20 | *.cipd 21 | 22 | # Build directories are produced when building using the Flutter CLI. 23 | build 24 | 25 | # This file is produced as a back-up when web_benchmarks fails to parse a 26 | # Chrome trace. 27 | chrome-trace.json 28 | 29 | # Generated files on example apps 30 | flutter_export_environment.sh 31 | .flutter-plugins* 32 | local.properties 33 | keystore.properties 34 | **/Flutter/Generated.xcconfig 35 | **/Flutter/App.framework/ 36 | **/Flutter/ephemeral/ 37 | **/Flutter/Flutter.podspec 38 | **/Flutter/Flutter.framework/ 39 | **/Flutter/flutter_assets/ 40 | 41 | ServiceDefinitions.json 42 | xcuserdata/ 43 | **/DerivedData/ 44 | 45 | generated_plugin_registrant.* 46 | GeneratedPluginRegistrant.* 47 | 48 | # Gradle 49 | **/gradle-wrapper.jar 50 | .gradle/ 51 | gradlew 52 | gradlew.bat 53 | 54 | .project 55 | .classpath 56 | .settings 57 | 58 | # Melos 59 | pubspec_overrides.yaml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber 2 | 3 | This is the monorepo containing all of the related packages for `flutter_libphonenumber`. 4 | 5 | We use `melos` to manage the packages. 6 | 7 | ## Getting started 8 | ```bash 9 | $ flutter pub get 10 | $ flutter pub run melos bootstrap 11 | ``` -------------------------------------------------------------------------------- /all_lint_rules.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # in the LICENSE file. 4 | linter: 5 | rules: 6 | - always_declare_return_types 7 | - always_put_control_body_on_new_line 8 | - always_put_required_named_parameters_first 9 | - always_require_non_null_named_parameters 10 | - always_specify_types 11 | - always_use_package_imports 12 | - annotate_overrides 13 | - avoid_annotating_with_dynamic 14 | - avoid_bool_literals_in_conditional_expressions 15 | - avoid_catches_without_on_clauses 16 | - avoid_catching_errors 17 | - avoid_classes_with_only_static_members 18 | - avoid_double_and_int_checks 19 | - avoid_dynamic_calls 20 | - avoid_empty_else 21 | - avoid_equals_and_hash_code_on_mutable_classes 22 | - avoid_escaping_inner_quotes 23 | - avoid_field_initializers_in_const_classes 24 | - avoid_function_literals_in_foreach_calls 25 | - avoid_implementing_value_types 26 | - avoid_init_to_null 27 | - avoid_js_rounded_ints 28 | - avoid_multiple_declarations_per_line 29 | - avoid_null_checks_in_equality_operators 30 | - avoid_positional_boolean_parameters 31 | - avoid_print 32 | - avoid_private_typedef_functions 33 | - avoid_redundant_argument_values 34 | - avoid_relative_lib_imports 35 | - avoid_renaming_method_parameters 36 | - avoid_return_types_on_setters 37 | - avoid_returning_null 38 | - avoid_returning_null_for_future 39 | - avoid_returning_null_for_void 40 | - avoid_returning_this 41 | - avoid_setters_without_getters 42 | - avoid_shadowing_type_parameters 43 | - avoid_single_cascade_in_expression_statements 44 | - avoid_slow_async_io 45 | - avoid_type_to_string 46 | - avoid_types_as_parameter_names 47 | - avoid_types_on_closure_parameters 48 | - avoid_unnecessary_containers 49 | - avoid_unused_constructor_parameters 50 | - avoid_void_async 51 | - avoid_web_libraries_in_flutter 52 | - await_only_futures 53 | - camel_case_extensions 54 | - camel_case_types 55 | - cancel_subscriptions 56 | - cascade_invocations 57 | - cast_nullable_to_non_nullable 58 | - close_sinks 59 | - comment_references 60 | - constant_identifier_names 61 | - control_flow_in_finally 62 | - curly_braces_in_flow_control_structures 63 | - depend_on_referenced_packages 64 | - deprecated_consistency 65 | - diagnostic_describe_all_properties 66 | - directives_ordering 67 | - do_not_use_environment 68 | - empty_catches 69 | - empty_constructor_bodies 70 | - empty_statements 71 | - eol_at_end_of_file 72 | - exhaustive_cases 73 | - file_names 74 | - flutter_style_todos 75 | - hash_and_equals 76 | - implementation_imports 77 | - invariant_booleans 78 | - iterable_contains_unrelated_type 79 | - join_return_with_assignment 80 | - leading_newlines_in_multiline_strings 81 | - library_names 82 | - library_prefixes 83 | - library_private_types_in_public_api 84 | - lines_longer_than_80_chars 85 | - list_remove_unrelated_type 86 | - literal_only_boolean_expressions 87 | - missing_whitespace_between_adjacent_strings 88 | - no_adjacent_strings_in_list 89 | - no_default_cases 90 | - no_duplicate_case_values 91 | - no_logic_in_create_state 92 | - no_runtimeType_toString 93 | - non_constant_identifier_names 94 | - noop_primitive_operations 95 | - null_check_on_nullable_type_parameter 96 | - null_closures 97 | - omit_local_variable_types 98 | - one_member_abstracts 99 | - only_throw_errors 100 | - overridden_fields 101 | - package_api_docs 102 | - package_names 103 | - package_prefixed_library_names 104 | - parameter_assignments 105 | - prefer_adjacent_string_concatenation 106 | - prefer_asserts_in_initializer_lists 107 | - prefer_asserts_with_message 108 | - prefer_collection_literals 109 | - prefer_conditional_assignment 110 | - prefer_const_constructors 111 | - prefer_const_constructors_in_immutables 112 | - prefer_const_declarations 113 | - prefer_const_literals_to_create_immutables 114 | - prefer_constructors_over_static_methods 115 | - prefer_contains 116 | - prefer_double_quotes 117 | - prefer_equal_for_default_values 118 | - prefer_expression_function_bodies 119 | - prefer_final_fields 120 | - prefer_final_in_for_each 121 | - prefer_final_locals 122 | - prefer_final_parameters 123 | - prefer_for_elements_to_map_fromIterable 124 | - prefer_foreach 125 | - prefer_function_declarations_over_variables 126 | - prefer_generic_function_type_aliases 127 | - prefer_if_elements_to_conditional_expressions 128 | - prefer_if_null_operators 129 | - prefer_initializing_formals 130 | - prefer_inlined_adds 131 | - prefer_int_literals 132 | - prefer_interpolation_to_compose_strings 133 | - prefer_is_empty 134 | - prefer_is_not_empty 135 | - prefer_is_not_operator 136 | - prefer_iterable_whereType 137 | - prefer_mixin 138 | - prefer_null_aware_method_calls 139 | - prefer_null_aware_operators 140 | - prefer_relative_imports 141 | - prefer_single_quotes 142 | - prefer_spread_collections 143 | - prefer_typing_uninitialized_variables 144 | - prefer_void_to_null 145 | - provide_deprecation_message 146 | - public_member_api_docs 147 | - recursive_getters 148 | - require_trailing_commas 149 | - sized_box_for_whitespace 150 | - slash_for_doc_comments 151 | - sort_child_properties_last 152 | - sort_constructors_first 153 | - sort_pub_dependencies 154 | - sort_unnamed_constructors_first 155 | - test_types_in_equals 156 | - throw_in_finally 157 | - tighten_type_of_initializing_formals 158 | - type_annotate_public_apis 159 | - type_init_formals 160 | - unawaited_futures 161 | - unnecessary_await_in_return 162 | - unnecessary_brace_in_string_interps 163 | - unnecessary_const 164 | - unnecessary_final 165 | - unnecessary_getters_setters 166 | - unnecessary_lambdas 167 | - unnecessary_new 168 | - unnecessary_null_aware_assignments 169 | - unnecessary_null_checks 170 | - unnecessary_null_in_if_null_operators 171 | - unnecessary_nullable_for_final_variable_declarations 172 | - unnecessary_overrides 173 | - unnecessary_parenthesis 174 | - unnecessary_raw_strings 175 | - unnecessary_statements 176 | - unnecessary_string_escapes 177 | - unnecessary_string_interpolations 178 | - unnecessary_this 179 | - unrelated_type_equality_checks 180 | - unsafe_html 181 | - use_build_context_synchronously 182 | - use_full_hex_values_for_flutter_colors 183 | - use_function_type_syntax_for_parameters 184 | - use_if_null_to_convert_nulls_to_bools 185 | - use_is_even_rather_than_modulo 186 | - use_key_in_widget_constructors 187 | - use_late_for_private_fields_and_variables 188 | - use_named_constants 189 | - use_raw_strings 190 | - use_rethrow_when_possible 191 | - use_setters_to_change_properties 192 | - use_string_buffers 193 | - use_test_throws_matchers 194 | - use_to_and_as_if_applicable 195 | - valid_regexps 196 | - void_checks 197 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: all_lint_rules.yaml 2 | 3 | analyzer: 4 | language: 5 | strict-inference: true 6 | 7 | # strong-mode: 8 | # implicit-casts: false 9 | # implicit-dynamic: false 10 | 11 | errors: 12 | # Otherwise cause the import of all_lint_rules to warn because of some rules conflicts. 13 | # We explicitly enabled even conflicting rules and are fixing the conflict 14 | # in this file 15 | included_file_warning: ignore 16 | 17 | # Things we really want to enforce in our code 18 | always_use_package_imports: error 19 | prefer_final_parameters: error 20 | prefer_final_fields: error 21 | prefer_final_in_for_each: error 22 | prefer_final_locals: error 23 | require_trailing_commas: error 24 | avoid_unused_constructor_parameters: error 25 | use_named_constants: error 26 | avoid_field_initializers_in_const_classes: error 27 | missing_default_value_for_parameter: error 28 | sort_constructors_first: error 29 | sort_unnamed_constructors_first: error 30 | sort_child_properties_last: error 31 | inference_failure_on_function_invocation: error 32 | todo: ignore # Todos are just informational 33 | 34 | linter: 35 | rules: 36 | prefer_double_quotes: false 37 | avoid_function_literals_in_foreach_calls: false 38 | non_constant_identifier_names: false 39 | public_member_api_docs: false 40 | diagnostic_describe_all_properties: false 41 | prefer_expression_function_bodies: false 42 | prefer_asserts_with_message: false 43 | prefer_mixin: false 44 | avoid_catches_without_on_clauses: false 45 | avoid_classes_with_only_static_members: false 46 | library_private_types_in_public_api: false 47 | comment_references: false 48 | avoid_bool_literals_in_conditional_expressions: false 49 | avoid_positional_boolean_parameters: false 50 | only_throw_errors: false 51 | join_return_with_assignment: false 52 | use_if_null_to_convert_nulls_to_bools: false 53 | use_setters_to_change_properties: false 54 | no_default_cases: false 55 | flutter_style_todos: false 56 | avoid_setters_without_getters: false 57 | sort_pub_dependencies: false 58 | avoid_dynamic_calls: false # nice to have one day 59 | avoid_redundant_argument_values: false # It's ok to be redundant to be explicit and clear 60 | avoid_annotating_with_dynamic: false # it's ok to be extra explicit 61 | 62 | # For compatibility with Scope 63 | no_runtimeType_toString: false 64 | avoid_types_on_closure_parameters: false 65 | 66 | # Things we have disabled on purpose 67 | unnecessary_final: false # we always want to use final whenever possible 68 | prefer_relative_imports: false # we always want to use package imports 69 | lines_longer_than_80_chars: false # Sometimes this makes it even harder to read than if it was one longer line 70 | omit_local_variable_types: false # We always want to be explicit 71 | always_specify_types: false # this gets a little too crazy/redundant and there's no auto-fix yet 72 | avoid_js_rounded_ints: false # we will never be compiling to javascript so we can ignore this 73 | depend_on_referenced_packages: false # this one does not appear to work - says we are missing deps we have in our pubspec. 74 | cascade_invocations: false # this can get confusing to understand sometimes. 75 | use_build_context_synchronously: false # still experimental but it's a good idea to follow eventually. 76 | always_put_required_named_parameters_first: false # nice to have but 600+ errors to fix by hand 77 | one_member_abstracts: false # interferes with our interface pattern for IoC across modules 78 | -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | # Name of this workspace, this is used for display purpose on the CLI 2 | # and on your IDEs. 3 | name: flutter_libphonenumber_workspace 4 | 5 | # versioning: 6 | # # Versioning mode, currently only independent supported. 7 | # mode: independent 8 | 9 | # Array of globs to search for packages. 10 | packages: 11 | - packages/** 12 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 8 | channel: stable 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 17 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 18 | - platform: android 19 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 20 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 21 | - platform: ios 22 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 23 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 24 | 25 | # User provided section 26 | 27 | # List of Local paths (relative to this file) that should be 28 | # ignored by the migrate tool. 29 | # 30 | # Files that are not part of the templates will be ignored by default. 31 | unmanaged_files: 32 | - 'lib/main.dart' 33 | - 'ios/Runner.xcodeproj/project.pbxproj' 34 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.5.1] - 2024.09.19 2 | 3 | - Bump flutter_libphonenumber_android to 1.4.1: This fixes unresolved Registrar issue occurring after upgrading Flutter to 3.29.0 (#93 @amitkhairnar44) 4 | 5 | ## [2.5.0] - 2024.09.19 6 | 7 | - Bump flutter_libphonenumber_platform_interface to 2.1.0 8 | - Bump flutter_libphonenumber_android to v1.4.0. 9 | - Bump flutter_libphonenumber_ios to v1.4.0. 10 | - Bump flutter_libphonenumber_web to v1.3.0. 11 | 12 | ## [2.4.0] - 2024.09.18 13 | 14 | - Bump flutter_libphonenumber_platform_interface to 2.0.0 15 | - Bump flutter_libphonenumber_android to v1.3.0. 16 | - Bump flutter_libphonenumber_ios to v1.3.0. 17 | - Bump flutter_libphonenumber_web to v1.2.0. 18 | 19 | ## [2.3.3] - 2024.08.19 20 | 21 | - Bump flutter_libphonenumber_android to v1.2.0. 22 | 23 | ## [2.3.2] - 2024.08.19 24 | 25 | - Bump flutter_libphonenumber_ios to v1.2.2. 26 | 27 | ## [2.3.1] - 2024.08.19 28 | 29 | - Bump flutter_libphonenumber_android to v1.1.0. 30 | 31 | ## [2.2.3] - 2024.04.16 32 | 33 | - Bump flutter_libphonenumber_web to v1.0.1. 34 | 35 | ## [2.2.2] - 2024.04.16 36 | 37 | - Bump flutter_libphonenumber_ios to v1.2.1. 38 | 39 | ## [2.2.1] - 2023.12.07 40 | 41 | - Fix init method overrides, from @nikolaychernov. 42 | 43 | ## [2.2.0] - 2023.12.07 44 | 45 | - Bump flutter_libphonenumber_ios to v1.2.0. 46 | - _BREAKING_ Raises minimum iOS deployment to 12.0. 47 | 48 | ## [2.1.5] - 2023.07.19 49 | 50 | - Bump flutter_libphonenumber_ios to v1.1.4. 51 | 52 | ## [2.1.4] - 2023.06.08 53 | 54 | - Bump flutter_libphonenumber_ios to v1.1.3. 55 | 56 | ## [2.1.3] - 2023.05.17 57 | 58 | - Fix pod issue with PhoneNumberKit by bumping flutter_libphonenumber_ios version to latest. 59 | 60 | ## [2.1.2] - 2023.05.01 61 | 62 | - Fix compatibility with AGP 8.0 (#43). 63 | 64 | ## [2.1.1] - 2023.05.01 65 | 66 | - Fix pod configuration for PhoneNumberKit. 67 | 68 | ## [2.1.0] - 2023.05.01 69 | 70 | - BREAKING: Bumped flutter_libphonenumber_ios to 1.1.0 which includes the latest PhoneNumberKit version. You must include the entry in your Podfile now. See updated README for details. 71 | 72 | ## [2.0.0] - 2023.03.23 73 | 74 | - Migrated to new federated plugin configuration. 75 | - Added web implementation from laynor. 76 | 77 | ## [1.4.0] - 2023.03.07 78 | 79 | - Fixed `onFormatFinished` callback not being called when `shouldKeepCursorAtEndOfInput=true`. 80 | 81 | ## [1.3.0] - 2022.12.05 82 | 83 | - Adds a new field (region_code) to the result of the parse method. 84 | - Upgrades the dependencies: 85 | - libphonenumber to 8.12.52 86 | - PhoneNumberKit to 3.3.4 87 | - Fixes some lint issues. 88 | - Upgrade gradle/kotlin versions in android project. 89 | 90 | ## [1.2.4] - 2022.03.09 91 | 92 | - Fixed some edge cases with cursor position when `shouldKeepCursorAtEndOfInput` is set to `false` 93 | 94 | ## [1.2.3] - 2022.03.08 95 | 96 | - New optional setting `shouldKeepCursorAtEndOfInput` on `LibPhonenumberTextFormatter` which will either keep the cursor at the end of the input if the middle of the input is changed, or the cursor will remain at the same position as where it was edited. 97 | 98 | ## [1.2.2] - 2022.01.12 99 | 100 | - Replaced jcenter with maven central (JeremyLWright). 101 | 102 | ## [1.2.1] - 2021.09.11 103 | 104 | - Fixed bug where region was not passed to `parse` call in `getFormattedParseResult`. 105 | 106 | # 1.2.0 107 | 108 | - BREAKING: renamed `hideCountryCode` to `inputContainsCountryCode` in `LibPhonenumberTextFormatter`. 109 | - BREAKING: renamed `removeCountryCode` to `removeCountryCodeFromResult` and added new parameter `inputContainsCountryCode` in `formatNumberSync()`. Use this to accurately describe if the input number contains a country code and whether or not the result should strip that country code out. 110 | 111 | # 1.1.0 112 | 113 | - Improvements to how masking is performed. 114 | - Now allows for additional digits to be added on the end of the input mask for countries with varying number patterns. 115 | 116 | # 1.0.4 117 | 118 | - Fix number parsing issue by not attaching a leading '+' anymore. This fixes the problem parsing GB numbers starting with 07 which didn't have the 44 country code at the start. 119 | - Bumped libphonenumber version on android. 120 | 121 | # 1.0.3 122 | 123 | - Nullsafety for main version. 124 | - UK numbers will correctly remove leading 0 now on international numbers. 125 | 126 | # 1.0.2-nullsafety 127 | 128 | - Bumped underlying native lib versions. PhoneNumberKit -> 3.3.3, libphonenumber -> 8.12.17. 129 | 130 | # 1.0.1-nullsafety 131 | 132 | - Add constraint for flutter v1.10.0. 133 | 134 | # 1.0.0-nullsafety 135 | 136 | - Migrate to null safety. 137 | 138 | # 0.3.11 139 | 140 | - Update iOS minimum deployment to 9.0. 141 | 142 | # 0.3.10 143 | 144 | - Bumped PhoneNumberKit to 3.3 (iOS) and libphonenumber to 8.12.11 (Android). 145 | - Fixed overflows in example app on smaller devices. 146 | 147 | # 0.3.9 148 | 149 | - Bump android compileSdkVersion to 29. 150 | 151 | # 0.3.8 152 | 153 | - Downgrade Android minSdkVersion version from 21 to 18 and bump libphonenumber version from 8.12.5 to 8.12.10 via [#3](https://github.com/bottlepay/flutter_libphonenumber/pull/3). 154 | 155 | # 0.3.7 156 | 157 | - Fixed bug where device locale was not correctly detected on iOS. 158 | 159 | # 0.3.6 160 | 161 | - Hide debug printing. 162 | 163 | ## 0.3.5 164 | 165 | - Added ability to override country mask/phone data. Added fix for UK international numbers when someone pastes in a national format. 166 | 167 | ## 0.3.4 168 | 169 | - Fixed bug when formatting the very first number where it wouldn't move the text selection to the very end. 170 | 171 | ## 0.3.3 172 | 173 | - Fixed bug where realtime formatter didn't ignore leading country code if present when overrideSkipCountryCode was provided. 174 | 175 | ## 0.3.2 176 | 177 | - Fixed formatParsePhonenumberAsync to return the correct phone number international/national format based on what was requested. 178 | 179 | ## 0.3.1 180 | 181 | - Fixes to documentation. 182 | 183 | ## 0.3.0 184 | 185 | - Can now format based on the national or international format of a country's phone number. 186 | 187 | ## 0.2.0 188 | 189 | - Added ability to format numbers as either mobile or fixed line, while defaulting to mobile. 190 | 191 | ## 0.1.5 192 | 193 | - Cleanup 194 | 195 | ## 0.1.4 196 | 197 | - Fixed bugs in the way masking is applied which caused numbers to be formatted incorrectly to their mask. 198 | 199 | ## 0.1.3 200 | 201 | - Removed print statements 202 | - Countries list in CountryManager is now read-only outside of the lib 203 | 204 | ## 0.1.2 205 | 206 | - Added example gifs 207 | 208 | ## 0.1.1 209 | 210 | - Package metadata fixes 211 | 212 | ## 0.1.0 213 | 214 | - Initial release 215 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 17 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 18 | - platform: web 19 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 20 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_example 2 | 3 | Demonstrates how to use the flutter_libphonenumber plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.flutter_libphonenumber_example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 50 | minSdkVersion 18 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/kotlin/com/example/flutter_libphonenumber_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_libphonenumber_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Libphonenumber 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_libphonenumber_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_example 2 | description: Demonstrates how to use the flutter_libphonenumber plugin. 3 | publish_to: none 4 | 5 | environment: 6 | sdk: ">=2.19.0 <4.0.0" 7 | flutter: ">=3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | flutter_libphonenumber: 14 | path: ../ 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | 20 | flutter: 21 | uses-material-design: true 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/web/favicon.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/lib/flutter_libphonenumber.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 2 | 3 | export 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart' 4 | show 5 | CountryManager, 6 | CountryWithPhoneCode, 7 | FormatPhoneResult, 8 | LibPhonenumberTextFormatter, 9 | PhoneMask, 10 | PhoneNumberFormat, 11 | PhoneNumberType; 12 | 13 | @override 14 | Future> format( 15 | final String phone, 16 | final String region, 17 | ) async { 18 | return FlutterLibphonenumberPlatform.instance.format(phone, region); 19 | } 20 | 21 | @override 22 | Future> getAllSupportedRegions() async { 23 | return FlutterLibphonenumberPlatform.instance.getAllSupportedRegions(); 24 | } 25 | 26 | @override 27 | Future> parse( 28 | final String phone, { 29 | final String? region, 30 | }) async { 31 | return FlutterLibphonenumberPlatform.instance.parse(phone, region: region); 32 | } 33 | 34 | @override 35 | Future init({ 36 | final Map overrides = const {}, 37 | }) async { 38 | return FlutterLibphonenumberPlatform.instance.init(overrides: overrides); 39 | } 40 | 41 | String formatNumberSync( 42 | final String number, { 43 | final CountryWithPhoneCode? country, 44 | final PhoneNumberType phoneNumberType = PhoneNumberType.mobile, 45 | final PhoneNumberFormat phoneNumberFormat = PhoneNumberFormat.international, 46 | final bool removeCountryCodeFromResult = false, 47 | final bool inputContainsCountryCode = true, 48 | }) { 49 | return FlutterLibphonenumberPlatform.instance.formatNumberSync( 50 | number, 51 | country: country, 52 | phoneNumberType: phoneNumberType, 53 | phoneNumberFormat: phoneNumberFormat, 54 | removeCountryCodeFromResult: removeCountryCodeFromResult, 55 | inputContainsCountryCode: inputContainsCountryCode, 56 | ); 57 | } 58 | 59 | Future getFormattedParseResult( 60 | final String phoneNumber, 61 | final CountryWithPhoneCode country, { 62 | final PhoneNumberType phoneNumberType = PhoneNumberType.mobile, 63 | final PhoneNumberFormat phoneNumberFormat = PhoneNumberFormat.international, 64 | }) async { 65 | return FlutterLibphonenumberPlatform.instance.getFormattedParseResult( 66 | phoneNumber, 67 | country, 68 | phoneNumberType: phoneNumberType, 69 | phoneNumberFormat: phoneNumberFormat, 70 | ); 71 | } 72 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber 2 | description: Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. 3 | repository: https://github.com/bottlepay/flutter_libphonenumber/tree/main/packages/flutter_libphonenumber 4 | issue_tracker: https://github.com/bottlepay/flutter_libphonenumber/issues 5 | version: 2.5.1 6 | 7 | environment: 8 | sdk: ">=2.19.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | flutter: 12 | plugin: 13 | platforms: 14 | android: 15 | default_package: flutter_libphonenumber_android 16 | ios: 17 | default_package: flutter_libphonenumber_ios 18 | web: 19 | default_package: flutter_libphonenumber_web 20 | # linux: 21 | # default_package: flutter_libphonenumber_linux 22 | # macos: 23 | # default_package: flutter_libphonenumber_macos 24 | # windows: 25 | # default_package: flutter_libphonenumber_windows 26 | 27 | dependencies: 28 | flutter: 29 | sdk: flutter 30 | flutter_libphonenumber_android: ^1.4.1 31 | flutter_libphonenumber_ios: ^1.4.0 32 | flutter_libphonenumber_platform_interface: ^2.1.0 33 | flutter_libphonenumber_web: ^1.3.0 34 | 35 | dev_dependencies: 36 | flutter_test: 37 | sdk: flutter 38 | plugin_platform_interface: ^2.1.4 39 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.4.1] - 2025.02.13 2 | 3 | - This fixes unresolved Registrar issue occurring after upgrading Flutter to 3.29.0 (#93 @amitkhairnar44) 4 | 5 | ## [1.4.0] - 2024.09.19 6 | 7 | - Bump flutter_libphonenumber_platform_interface to 2.1.0 8 | 9 | ## [1.3.0] - 2024.09.18 10 | 11 | - Bump flutter_libphonenumber_platform_interface to 2.0.0 12 | 13 | ## [1.2.0] - 2024.08.19 14 | 15 | - Bump libphonenumber to 8.13.43. 16 | 17 | ## [1.1.0] - 2024.08.19 18 | 19 | - Bump android compileSdk to 34 20 | - Fix android JVM version incompatibility build errors. 21 | 22 | ## 1.0.1 23 | 24 | - Fix compatibility with AGP 8.0 (#43). 25 | 26 | ## 1.0.0 27 | 28 | - Initial release after migration to federated plugin. 29 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_android 2 | 3 | Android platform implementation for `flutter_libphonenumber`. 4 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.bottlepay.flutter_libphonenumber' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.7.10' 6 | repositories { 7 | google() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:8.1.4' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | if (project.android.hasProperty("namespace")) { 29 | namespace("com.bottlepay.flutter_libphonenumber") 30 | } 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_17 34 | targetCompatibility JavaVersion.VERSION_17 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '17' 39 | } 40 | 41 | compileSdk 34 42 | 43 | sourceSets { 44 | main.java.srcDirs += 'src/main/kotlin' 45 | } 46 | defaultConfig { 47 | minSdkVersion 18 48 | } 49 | lintOptions { 50 | disable 'InvalidPackage' 51 | } 52 | } 53 | 54 | dependencies { 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 56 | implementation "com.googlecode.libphonenumber:libphonenumber:8.13.43" 57 | } 58 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 6 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_libphonenumber' 2 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/android/src/main/kotlin/com/bottlepay/flutter_libphonenumber/FlutterLibphonenumberPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.bottlepay.flutter_libphonenumber 2 | 3 | import android.os.Handler 4 | import android.os.Looper 5 | import androidx.annotation.NonNull 6 | import com.google.i18n.phonenumbers.NumberParseException 7 | import com.google.i18n.phonenumbers.PhoneNumberUtil 8 | import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType 9 | import com.google.i18n.phonenumbers.Phonenumber 10 | import io.flutter.embedding.engine.plugins.FlutterPlugin 11 | import io.flutter.plugin.common.MethodCall 12 | import io.flutter.plugin.common.MethodChannel 13 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 14 | import io.flutter.plugin.common.MethodChannel.Result 15 | import java.util.* 16 | 17 | 18 | /** FlutterLibphonenumberPlugin */ 19 | public class FlutterLibphonenumberPlugin : FlutterPlugin, MethodCallHandler { 20 | /// The MethodChannel that will the communication between Flutter and native Android 21 | /// 22 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 23 | /// when the Flutter Engine is detached from the Activity 24 | private lateinit var channel: MethodChannel 25 | 26 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 27 | channel = MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "com.bottlepay/flutter_libphonenumber_android") 28 | channel.setMethodCallHandler(this); 29 | } 30 | 31 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 32 | when (call.method) { 33 | "get_all_supported_regions" -> { 34 | getAllSupportedRegions(result) 35 | } 36 | "parse" -> { 37 | parse(call, result) 38 | } 39 | "format" -> { 40 | format(call, result) 41 | } else -> { 42 | result.notImplemented() 43 | } 44 | } 45 | } 46 | 47 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 48 | channel.setMethodCallHandler(null) 49 | } 50 | 51 | // Send a result back to dart over the method channel 52 | private fun sendDartResult(resultName: String, resultData: T) { 53 | channel.invokeMethod(resultName, mapOf(Pair("result", resultData))) 54 | } 55 | 56 | // Parse a given phone number and region to get metadata back about it 57 | private fun parse(call: MethodCall, result: Result) { 58 | val region = call.argument("region") 59 | val phone = call.argument("phone") 60 | 61 | if (phone == null || phone.isEmpty()) { 62 | result.error("InvalidParameters", "Invalid 'phone' parameter.", null) 63 | } else { 64 | val util = PhoneNumberUtil.getInstance() 65 | val res: HashMap? = parseStringAndRegion(phone, region, util) 66 | if (res != null) { 67 | result.success(res) 68 | } else { 69 | result.error("InvalidNumber", "Number $phone is invalid", null) 70 | } 71 | } 72 | } 73 | 74 | // Gathers all of the supported regions on another thread and sends them back to Dart when ready 75 | private fun getAllSupportedRegions(result: Result) { 76 | Thread(Runnable { 77 | val regionsMap = mutableMapOf>() 78 | for (region in PhoneNumberUtil.getInstance().supportedRegions) { 79 | val itemMap = mutableMapOf() 80 | // Save the phone code 81 | val phoneCode = PhoneNumberUtil.getInstance().getCountryCodeForRegion(region).toString() 82 | itemMap["phoneCode"] = phoneCode 83 | 84 | 85 | // Get a formatted example number 86 | val exampleNumberMobile = PhoneNumberUtil.getInstance().getExampleNumberForType(region, PhoneNumberType.MOBILE) ?: Phonenumber.PhoneNumber() 87 | val exampleNumberFixedLine = PhoneNumberUtil.getInstance().getExampleNumberForType(region, PhoneNumberType.FIXED_LINE) ?: Phonenumber.PhoneNumber() 88 | itemMap["exampleNumberMobileNational"] = formatNational(exampleNumberMobile).toString() 89 | itemMap["exampleNumberFixedLineNational"] = formatNational(exampleNumberFixedLine).toString() 90 | itemMap["phoneMaskMobileNational"] = maskNumber(formatNational(exampleNumberMobile).toString(), phoneCode) 91 | itemMap["phoneMaskFixedLineNational"] = maskNumber(formatNational(exampleNumberFixedLine).toString(), phoneCode) 92 | itemMap["exampleNumberMobileInternational"] = formatInternational(exampleNumberMobile).toString() 93 | itemMap["exampleNumberFixedLineInternational"] = formatInternational(exampleNumberFixedLine).toString() 94 | itemMap["phoneMaskMobileInternational"] = maskNumber(formatInternational(exampleNumberMobile).toString(), phoneCode) 95 | itemMap["phoneMaskFixedLineInternational"] = maskNumber(formatInternational(exampleNumberFixedLine).toString(), phoneCode) 96 | itemMap["countryName"] = Locale("",region).displayCountry 97 | 98 | // Save this map into the return map 99 | regionsMap[region] = itemMap 100 | } 101 | Handler(Looper.getMainLooper()).post(Runnable { 102 | result.success(regionsMap) 103 | }) 104 | }).start() 105 | } 106 | 107 | // Masks a phone number by replacing all digits with 0s 108 | private fun maskNumber(phoneNumber: String, phoneCode: String) = phoneNumber.replace(Regex("""[\d]"""), "0") 109 | private fun formatNational(phoneNumber: Phonenumber.PhoneNumber) = PhoneNumberUtil.getInstance().format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.NATIONAL) 110 | private fun formatInternational(phoneNumber: Phonenumber.PhoneNumber) = PhoneNumberUtil.getInstance().format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL) 111 | 112 | private fun parseStringAndRegion(string: String, region: String?, 113 | util: PhoneNumberUtil): HashMap? { 114 | return try { 115 | val phoneNumber = util.parse(string, region) 116 | if (!util.isValidNumber(phoneNumber)) { 117 | null 118 | } else object : HashMap() { 119 | init { 120 | val type = util.getNumberType(phoneNumber) 121 | put("type", numberTypeToString(type)) 122 | put("e164", util.format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.E164)) 123 | put("international", 124 | util.format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL)) 125 | put("national", util.format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.NATIONAL)) 126 | put("country_code", phoneNumber.countryCode.toString()) 127 | put("region_code", util.getRegionCodeForNumber(phoneNumber)) 128 | put("national_number", phoneNumber.nationalNumber.toString()) 129 | } 130 | } 131 | 132 | // Try to parse the string to a phone number for a given region. 133 | 134 | // If the parsing is successful, we return a map containing : 135 | // - the number in the E164 format 136 | // - the number in the international format 137 | // - the number formatted as a national number and without the international prefix 138 | // - the type of number (might not be 100% accurate) 139 | } catch (e: NumberParseException) { 140 | null 141 | } 142 | } 143 | 144 | private fun format(call: MethodCall, result: Result) { 145 | val region = call.argument("region") 146 | val phone = call.argument("phone") 147 | if (phone == null) { 148 | result.error("InvalidParameters", "Invalid 'string' parameter.", null) 149 | return 150 | } 151 | try { 152 | val util = PhoneNumberUtil.getInstance() 153 | val formatter = util.getAsYouTypeFormatter(region) 154 | var formatted = "" 155 | formatter.clear() 156 | for (character in phone.toCharArray()) { 157 | formatted = formatter.inputDigit(character) 158 | } 159 | val res = HashMap() 160 | res["formatted"] = formatted 161 | result.success(res) 162 | } catch (exception: Exception) { 163 | result.error("InvalidNumber", "Number $phone is invalid", null) 164 | } 165 | } 166 | 167 | private fun numberTypeToString(type: PhoneNumberType): String { 168 | return when (type) { 169 | PhoneNumberType.FIXED_LINE -> "fixedLine" 170 | PhoneNumberType.MOBILE -> "mobile" 171 | PhoneNumberType.FIXED_LINE_OR_MOBILE -> "fixedOrMobile" 172 | PhoneNumberType.TOLL_FREE -> "tollFree" 173 | PhoneNumberType.PREMIUM_RATE -> "premiumRate" 174 | PhoneNumberType.SHARED_COST -> "sharedCost" 175 | PhoneNumberType.VOIP -> "voip" 176 | PhoneNumberType.PERSONAL_NUMBER -> "personalNumber" 177 | PhoneNumberType.PAGER -> "pager" 178 | PhoneNumberType.UAN -> "uan" 179 | PhoneNumberType.VOICEMAIL -> "voicemail" 180 | PhoneNumberType.UNKNOWN -> "unknown" 181 | else -> "notParsed" 182 | } 183 | } 184 | } 185 | 186 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_android_example 2 | 3 | Demonstrates how to use the flutter_libphonenumber_android plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | compileSdk flutter.compileSdkVersion 27 | ndkVersion flutter.ndkVersion 28 | 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | 34 | kotlinOptions { 35 | jvmTarget = '1.8' 36 | } 37 | 38 | sourceSets { 39 | main.java.srcDirs += 'src/main/kotlin' 40 | } 41 | 42 | defaultConfig { 43 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 44 | applicationId "com.bottlepay.flutter_libphonenumber_android_example" 45 | // You can update the following values to match your application needs. 46 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 47 | minSdkVersion flutter.minSdkVersion 48 | targetSdkVersion flutter.targetSdkVersion 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | namespace 'com.bottlepay.flutter_libphonenumber_android_example' 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies {} 68 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/kotlin/com/bottlepay/flutter_libphonenumber_android_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.bottlepay.flutter_libphonenumber_android_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = '../build' 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(':app') 14 | } 15 | 16 | tasks.register('clean', Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | android.defaults.buildfeatures.buildconfig=true 5 | android.nonTransitiveRClass=false 6 | android.nonFinalResIds=false 7 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip 6 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "8.1.4" apply false 22 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 23 | } 24 | 25 | include ":app" -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_android_example 2 | description: Demonstrates how to use the flutter_libphonenumber_android plugin. 3 | publish_to: none 4 | 5 | environment: 6 | sdk: ">=2.19.0 <4.0.0" 7 | flutter: ">=3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | flutter_libphonenumber_android: 14 | path: ../ 15 | flutter_libphonenumber_platform_interface: ^2.1.0 16 | 17 | cupertino_icons: ^1.0.2 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | 23 | flutter: 24 | uses-material-design: true 25 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/lib/flutter_libphonenumber_android.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 3 | 4 | const _channel = MethodChannel('com.bottlepay/flutter_libphonenumber_android'); 5 | 6 | class FlutterLibphonenumberAndroid extends FlutterLibphonenumberPlatform { 7 | /// Registers this class as the default instance of [FlutterLibphonenumberPlatform]. 8 | static void registerWith() { 9 | FlutterLibphonenumberPlatform.instance = FlutterLibphonenumberAndroid(); 10 | } 11 | 12 | @override 13 | Future> format( 14 | final String phone, 15 | final String region, 16 | ) async { 17 | return await _channel.invokeMapMethod('format', { 18 | 'phone': phone, 19 | 'region': region, 20 | }) ?? 21 | {}; 22 | } 23 | 24 | @override 25 | Future> getAllSupportedRegions() async { 26 | final result = await _channel 27 | .invokeMapMethod('get_all_supported_regions') ?? 28 | {}; 29 | 30 | final returnMap = {}; 31 | result.forEach( 32 | (final k, final v) => returnMap[k] = CountryWithPhoneCode( 33 | countryName: v['countryName'] ?? '', 34 | phoneCode: v['phoneCode'] ?? '', 35 | countryCode: k, 36 | exampleNumberMobileNational: v['exampleNumberMobileNational'] ?? '', 37 | exampleNumberFixedLineNational: 38 | v['exampleNumberFixedLineNational'] ?? '', 39 | phoneMaskMobileNational: v['phoneMaskMobileNational'] ?? '', 40 | phoneMaskFixedLineNational: v['phoneMaskFixedLineNational'] ?? '', 41 | exampleNumberMobileInternational: 42 | v['exampleNumberMobileInternational'] ?? '', 43 | exampleNumberFixedLineInternational: 44 | v['exampleNumberFixedLineInternational'] ?? '', 45 | phoneMaskMobileInternational: v['phoneMaskMobileInternational'] ?? '', 46 | phoneMaskFixedLineInternational: 47 | v['phoneMaskFixedLineInternational'] ?? '', 48 | ), 49 | ); 50 | return returnMap; 51 | } 52 | 53 | @override 54 | Future> parse( 55 | final String phone, { 56 | final String? region, 57 | }) async { 58 | return await _channel.invokeMapMethod('parse', { 59 | 'phone': phone, 60 | 'region': region, 61 | }) ?? 62 | {}; 63 | } 64 | 65 | @override 66 | Future init({ 67 | final Map overrides = const {}, 68 | }) async { 69 | return CountryManager().loadCountries( 70 | phoneCodesMap: await getAllSupportedRegions(), 71 | overrides: overrides, 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_android/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_android 2 | description: Android implementation of the flutter_libphonenumber plugin. 3 | repository: https://github.com/bottlepay/flutter_libphonenumber/tree/main/packages/flutter_libphonenumber_android 4 | issue_tracker: https://github.com/bottlepay/flutter_libphonenumber/issues 5 | version: 1.4.1 6 | 7 | environment: 8 | sdk: ">=2.19.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | flutter: 12 | plugin: 13 | implements: flutter_libphonenumber 14 | platforms: 15 | android: 16 | package: com.bottlepay.flutter_libphonenumber 17 | pluginClass: FlutterLibphonenumberPlugin 18 | dartPluginClass: FlutterLibphonenumberAndroid 19 | 20 | dependencies: 21 | flutter: 22 | sdk: flutter 23 | flutter_libphonenumber_platform_interface: ^2.1.0 24 | 25 | dev_dependencies: 26 | flutter_test: 27 | sdk: flutter 28 | plugin_platform_interface: ^2.0.2 29 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 8 | channel: stable 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 17 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 18 | - platform: ios 19 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 20 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.4.0] - 2024.09.19 2 | 3 | - Bump flutter_libphonenumber_platform_interface to 2.1.0 4 | 5 | ## [1.3.0] - 2024.09.18 6 | 7 | - Bump flutter_libphonenumber_platform_interface to 2.0.0 8 | 9 | ## [1.2.2] - 2024.08.19 10 | 11 | - Bump PhoneNumberKit to 3.8.0 12 | 13 | # 1.2.1 14 | 15 | - Bump PhoneNumberKit to 3.7.9 16 | - Added a Privacy Manifest to the iOS Project 17 | 18 | # 1.2.0 19 | 20 | - Bump PhoneNumberKit to 3.7.6. 21 | - _BREAKING_ Raises minimum iOS deployment to 12.0. 22 | 23 | # 1.1.4 24 | 25 | - Bump PhoneNumberKit to 3.6.6. 26 | 27 | # 1.1.3 28 | 29 | - Bump PhoneNumberKit to 3.6.0. 30 | 31 | # 1.1.2 32 | 33 | - Bump PhoneNumberKit to 3.5.10. 34 | 35 | # 1.1.1 36 | 37 | - Fix pod configuration for PhoneNumberKit. 38 | 39 | ## 1.1.0 40 | 41 | - Breaking: PhoneNumberKit pod must now be added to your Podfile because it is no longer published on cocoapods and must be downloaded from git. 42 | 43 | ## 1.0.0 44 | 45 | - Initial release after migration to federated plugin. 46 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_ios 2 | 3 | iOS platform implementation for `flutter_libphonenumber`. -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_ios_example 2 | 3 | Demonstrates how to use the flutter_libphonenumber_ios plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Libphonenumber Ios 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_libphonenumber_ios_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_ios_example 2 | description: Demonstrates how to use the flutter_libphonenumber plugin. 3 | publish_to: none 4 | 5 | environment: 6 | sdk: ">=2.19.0 <4.0.0" 7 | flutter: ">=3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | flutter_libphonenumber_ios: 14 | path: ../ 15 | flutter_libphonenumber_platform_interface: ^2.1.0 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | flutter: 22 | uses-material-design: true 23 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_ios/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/Classes/FlutterLibphonenumberPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterLibphonenumberPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/Classes/FlutterLibphonenumberPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterLibphonenumberPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_libphonenumber_ios-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterLibphonenumberPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterLibphonenumberPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/Resources/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrivacyTrackingDomains 6 | 7 | NSPrivacyAccessedAPITypes 8 | 9 | NSPrivacyCollectedDataTypes 10 | 11 | NSPrivacyTracking 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/ios/flutter_libphonenumber_ios.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_libphonenumber.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = "flutter_libphonenumber_ios" 7 | s.version = "1.1.4" 8 | s.summary = "Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting." 9 | s.description = <<-DESC 10 | Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting. 11 | DESC 12 | s.homepage = "https://github.com/bottlepay/flutter_libphonenumber" 13 | s.license = { :file => "../LICENSE" } 14 | s.author = { "Andrew Coutts" => "andrew.coutts@bottlepay.com" } 15 | s.source = { :path => "." } 16 | s.source_files = "Classes/**/*" 17 | s.dependency "Flutter" 18 | s.dependency "PhoneNumberKit/PhoneNumberKitCore", "3.8.0" 19 | s.platform = :ios, "12.0" 20 | 21 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 22 | s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES", "VALID_ARCHS[sdk=iphonesimulator*]" => "x86_64" } 23 | s.swift_version = "5.0" 24 | s.resource_bundles = {'flutter_libphonenumber_ios' => ['Resources/PrivacyInfo.xcprivacy']} 25 | end 26 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/lib/flutter_libphonenumber_ios.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 3 | 4 | const _channel = MethodChannel('com.bottlepay/flutter_libphonenumber_ios'); 5 | 6 | class FlutterLibphonenumberIOS extends FlutterLibphonenumberPlatform { 7 | /// Registers this class as the default instance of [FlutterLibphonenumberPlatform]. 8 | static void registerWith() { 9 | FlutterLibphonenumberPlatform.instance = FlutterLibphonenumberIOS(); 10 | } 11 | 12 | @override 13 | Future> format( 14 | final String phone, 15 | final String region, 16 | ) async { 17 | return await _channel.invokeMapMethod('format', { 18 | 'phone': phone, 19 | 'region': region, 20 | }) ?? 21 | {}; 22 | } 23 | 24 | @override 25 | Future> getAllSupportedRegions() async { 26 | final result = await _channel 27 | .invokeMapMethod('get_all_supported_regions') ?? 28 | {}; 29 | 30 | final returnMap = {}; 31 | result.forEach( 32 | (final k, final v) => returnMap[k] = CountryWithPhoneCode( 33 | countryName: v['countryName'] ?? '', 34 | phoneCode: v['phoneCode'] ?? '', 35 | countryCode: k, 36 | exampleNumberMobileNational: v['exampleNumberMobileNational'] ?? '', 37 | exampleNumberFixedLineNational: 38 | v['exampleNumberFixedLineNational'] ?? '', 39 | phoneMaskMobileNational: v['phoneMaskMobileNational'] ?? '', 40 | phoneMaskFixedLineNational: v['phoneMaskFixedLineNational'] ?? '', 41 | exampleNumberMobileInternational: 42 | v['exampleNumberMobileInternational'] ?? '', 43 | exampleNumberFixedLineInternational: 44 | v['exampleNumberFixedLineInternational'] ?? '', 45 | phoneMaskMobileInternational: v['phoneMaskMobileInternational'] ?? '', 46 | phoneMaskFixedLineInternational: 47 | v['phoneMaskFixedLineInternational'] ?? '', 48 | ), 49 | ); 50 | return returnMap; 51 | } 52 | 53 | @override 54 | Future> parse( 55 | final String phone, { 56 | final String? region, 57 | }) async { 58 | return await _channel.invokeMapMethod('parse', { 59 | 'phone': phone, 60 | 'region': region, 61 | }) ?? 62 | {}; 63 | } 64 | 65 | @override 66 | Future init({ 67 | final Map overrides = const {}, 68 | }) async { 69 | return CountryManager().loadCountries( 70 | phoneCodesMap: await getAllSupportedRegions(), 71 | overrides: overrides, 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_ios/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_ios 2 | description: iOS implementation of the flutter_libphonenumber plugin. 3 | repository: https://github.com/bottlepay/flutter_libphonenumber/tree/main/packages/flutter_libphonenumber_ios 4 | issue_tracker: https://github.com/bottlepay/flutter_libphonenumber/issues 5 | version: 1.4.0 6 | 7 | environment: 8 | sdk: ">=2.19.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | flutter: 12 | plugin: 13 | implements: flutter_libphonenumber 14 | platforms: 15 | ios: 16 | pluginClass: FlutterLibphonenumberPlugin 17 | dartPluginClass: FlutterLibphonenumberIOS 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | flutter_libphonenumber_platform_interface: ^2.1.0 23 | 24 | dev_dependencies: 25 | flutter_test: 26 | sdk: flutter 27 | plugin_platform_interface: ^2.1.4 28 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [2.1.0] - 2024.09.19 2 | 3 | - Fix `LibPhonenumberTextFormatter` formatting behavior for national vs international US numbers. 4 | 5 | ## [2.0.0] - 2024.09.18 6 | 7 | - Breaking: PhoneMask.apply now needs the country object to correclty filter out the country phone code from results. Fixes bugginess when using `PhoneNumberFormat.national` with `formatNumberSync()`. 8 | 9 | ## 1.0.0 10 | 11 | - Initial release after migration to federated plugin. 12 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_platform_interface 2 | 3 | Platform interface definition for `flutter_libphonenumber`. -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/flutter_libphonenumber_platform_interface.dart: -------------------------------------------------------------------------------- 1 | export 'src/platform_interface/flutter_libphonenumber_platform.dart'; 2 | export 'src/types/country_manager.dart'; 3 | export 'src/types/country_with_phone_code.dart'; 4 | export 'src/types/format_phone_result.dart'; 5 | export 'src/types/input_formatter.dart'; 6 | export 'src/types/phone_mask.dart'; 7 | export 'src/types/phone_number_format.dart'; 8 | export 'src/types/phone_number_type.dart'; 9 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/method_channel/flutter_libphonenumber_method_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 3 | 4 | const _channel = MethodChannel('com.bottlepay/flutter_libphonenumber'); 5 | 6 | /// An implementation of [FlutterLibphonenumberPlatform] that uses method channels. 7 | class MethodChannelFlutterLibphonenumber extends FlutterLibphonenumberPlatform { 8 | MethodChannelFlutterLibphonenumber(); 9 | 10 | @override 11 | Future> format( 12 | final String phone, 13 | final String region, 14 | ) async { 15 | return await _channel.invokeMapMethod('format', { 16 | 'phone': phone, 17 | 'region': region, 18 | }) ?? 19 | {}; 20 | } 21 | 22 | @override 23 | Future> getAllSupportedRegions() async { 24 | final result = await _channel 25 | .invokeMapMethod('get_all_supported_regions') ?? 26 | {}; 27 | 28 | final returnMap = {}; 29 | result.forEach( 30 | (final k, final v) => returnMap[k] = CountryWithPhoneCode( 31 | countryName: v['countryName'] ?? '', 32 | phoneCode: v['phoneCode'] ?? '', 33 | countryCode: k, 34 | exampleNumberMobileNational: v['exampleNumberMobileNational'] ?? '', 35 | exampleNumberFixedLineNational: 36 | v['exampleNumberFixedLineNational'] ?? '', 37 | phoneMaskMobileNational: v['phoneMaskMobileNational'] ?? '', 38 | phoneMaskFixedLineNational: v['phoneMaskFixedLineNational'] ?? '', 39 | exampleNumberMobileInternational: 40 | v['exampleNumberMobileInternational'] ?? '', 41 | exampleNumberFixedLineInternational: 42 | v['exampleNumberFixedLineInternational'] ?? '', 43 | phoneMaskMobileInternational: v['phoneMaskMobileInternational'] ?? '', 44 | phoneMaskFixedLineInternational: 45 | v['phoneMaskFixedLineInternational'] ?? '', 46 | ), 47 | ); 48 | return returnMap; 49 | } 50 | 51 | @override 52 | Future> parse( 53 | final String phone, { 54 | final String? region, 55 | }) async { 56 | return await _channel.invokeMapMethod('parse', { 57 | 'phone': phone, 58 | 'region': region, 59 | }) ?? 60 | {}; 61 | } 62 | 63 | @override 64 | Future init({ 65 | final Map overrides = const {}, 66 | }) async { 67 | return CountryManager().loadCountries( 68 | phoneCodesMap: await getAllSupportedRegions(), 69 | overrides: overrides, 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/platform_interface/flutter_libphonenumber_platform.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_libphonenumber_platform_interface/src/method_channel/flutter_libphonenumber_method_channel.dart'; 2 | import 'package:flutter_libphonenumber_platform_interface/src/types/country_with_phone_code.dart'; 3 | import 'package:flutter_libphonenumber_platform_interface/src/types/format_phone_result.dart'; 4 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_mask.dart'; 5 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_number_format.dart'; 6 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_number_type.dart'; 7 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 8 | 9 | abstract class FlutterLibphonenumberPlatform extends PlatformInterface { 10 | /// Constructs a FlutterLibphonenumberPlatform. 11 | FlutterLibphonenumberPlatform() : super(token: _token); 12 | 13 | static final Object _token = Object(); 14 | 15 | static FlutterLibphonenumberPlatform _instance = 16 | MethodChannelFlutterLibphonenumber(); 17 | 18 | /// The default instance of [FlutterLibphonenumberPlatform] to use. 19 | /// 20 | /// Defaults to [MethodChannelFlutterLibphonenumber]. 21 | static FlutterLibphonenumberPlatform get instance => _instance; 22 | 23 | /// Platform-specific implementations should set this with their own 24 | /// platform-specific class that extends [FlutterLibphonenumberPlatform] when 25 | /// they register themselves. 26 | static set instance(final FlutterLibphonenumberPlatform instance) { 27 | PlatformInterface.verifyToken(instance, _token); 28 | _instance = instance; 29 | } 30 | 31 | /// Return all available regions with their country code, phone code, and formatted 32 | /// example number as a mask. Useful to later format phone numbers using a mask. 33 | /// 34 | /// The response will be a [CountryWithPhoneCode]: 35 | /// 36 | /// There are some performance considerations for this so you might want to cache the 37 | /// result and re-use it elsewhere. There's a lot of data to iterate over. 38 | /// 39 | /// Here is what will return from the platform call: 40 | /// ``` 41 | /// { 42 | /// "UK": { 43 | /// "phoneCode": 44, 44 | /// "exampleNumberMobileNational": "07400 123456", 45 | /// "exampleNumberFixedLineNational": "0121 234 5678", 46 | /// "phoneMaskMobileNational": "+00 00000 000000", 47 | /// "phoneMaskFixedLineNational": "+00 0000 000 0000", 48 | /// "exampleNumberMobileInternational": "+44 7400 123456", 49 | /// "exampleNumberFixedLineInternational": "+44 121 234 5678", 50 | /// "phoneMaskMobileInternational": "+00 +00 0000 000000", 51 | /// "phoneMaskFixedLineInternational": "+00 +00 000 000 0000", 52 | /// "countryName": "United Kingdom" 53 | /// } 54 | /// } 55 | /// ``` 56 | Future> getAllSupportedRegions() async { 57 | throw UnimplementedError( 58 | 'getAllSupportedRegions() has not been implemented.', 59 | ); 60 | } 61 | 62 | /// Formats a phone number using platform libphonenumber. Will return the parsed number. 63 | /// 64 | /// Example response: 65 | /// ``` 66 | /// { 67 | /// formatted: "1 (414) 444-4444", 68 | /// } 69 | /// ``` 70 | Future> format( 71 | final String phone, 72 | final String region, 73 | ) async { 74 | throw UnimplementedError('format() has not been implemented.'); 75 | } 76 | 77 | /// Parse a single string and return a map in the format below. Throws an error if the 78 | /// number is not a valid e164 phone number. 79 | /// 80 | /// Given a passed [phone] like '+4930123123123', the response will be: 81 | /// ``` 82 | /// { 83 | /// country_code: 49, 84 | /// e164: '+4930123123123', 85 | /// national: '030 123 123 123', 86 | /// type: 'mobile', 87 | /// international: '+49 30 123 123 123', 88 | /// national_number: '030123123123', 89 | /// } 90 | /// ``` 91 | Future> parse( 92 | final String phone, { 93 | final String? region, 94 | }) async { 95 | throw UnimplementedError('parse() has not been implemented.'); 96 | } 97 | 98 | /// Must call this before anything else so the countries data is populated. 99 | /// 100 | /// Optionally provide a map of overrides where the key is the country code 101 | /// (ex: `GB` or `US`) and the value is a `CountryWithPhoneCode` object 102 | /// that should replace the data pulled from libphonenumber. This is useful 103 | /// if you want to customize the mask data for a given country. 104 | Future init({ 105 | final Map overrides = const {}, 106 | }) async { 107 | throw UnimplementedError('init() has not been implemented.'); 108 | } 109 | 110 | /// Given a phone number, format it automatically using the masks we have from 111 | /// libphonenumber's example numbers. Optionally override the country (instead 112 | /// of auto-detecting), the number type, format. 113 | /// 114 | /// Use [removeCountryCodeFromResult] to strip the country code from the result 115 | /// and set [inputContainsCountryCode] based on if the input contains a country 116 | /// code or not so the correct mask can be used. 117 | String formatNumberSync( 118 | final String number, { 119 | final CountryWithPhoneCode? country, 120 | final PhoneNumberType phoneNumberType = PhoneNumberType.mobile, 121 | final PhoneNumberFormat phoneNumberFormat = PhoneNumberFormat.international, 122 | final bool removeCountryCodeFromResult = false, 123 | final bool inputContainsCountryCode = true, 124 | }) { 125 | final guessedCountry = 126 | country ?? CountryWithPhoneCode.getCountryDataByPhone(number); 127 | 128 | if (guessedCountry == null) { 129 | return number; 130 | } 131 | 132 | var formatResult = PhoneMask( 133 | mask: guessedCountry.getPhoneMask( 134 | format: phoneNumberFormat, 135 | type: phoneNumberType, 136 | removeCountryCodeFromMask: !inputContainsCountryCode, 137 | ), 138 | country: guessedCountry, 139 | ).apply(number); 140 | 141 | /// Remove the country code from the result if the user set removeCountryCodeFromResult=true. 142 | /// Take a substring of the phone code length + 2 to account for leading `+` and space between 143 | /// country code and the number. 144 | if (removeCountryCodeFromResult && inputContainsCountryCode) { 145 | formatResult = 146 | formatResult.substring(guessedCountry.phoneCode.length + 2); 147 | } 148 | 149 | return formatResult; 150 | } 151 | 152 | /// Asynchronously formats a number, returning the e164 and the number's requested format 153 | /// result by specifying a [PhoneNumberType] and [PhoneNumberFormat]. 154 | /// 155 | /// If the number is invalid or cannot be parsed, it will return a null result. 156 | Future getFormattedParseResult( 157 | final String phoneNumber, 158 | final CountryWithPhoneCode country, { 159 | final PhoneNumberType phoneNumberType = PhoneNumberType.mobile, 160 | final PhoneNumberFormat phoneNumberFormat = PhoneNumberFormat.international, 161 | }) async { 162 | try { 163 | /// Try to parse the number and get our result 164 | final res = await parse( 165 | phoneNumber, 166 | region: country.countryCode, 167 | ); 168 | 169 | late final String formattedNumber; 170 | if (phoneNumberFormat == PhoneNumberFormat.international) { 171 | formattedNumber = res['international'] ?? ''; 172 | } else if (phoneNumberFormat == PhoneNumberFormat.national) { 173 | formattedNumber = res['national'] ?? ''; 174 | } else { 175 | /// Should never happen 176 | formattedNumber = ''; 177 | } 178 | 179 | /// Now construct the return value based on the requested format/type. 180 | return FormatPhoneResult( 181 | e164: res['e164'] ?? '', 182 | formattedNumber: formattedNumber, 183 | ); 184 | } catch (e) { 185 | // print(e); 186 | } 187 | 188 | return null; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/country_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_libphonenumber_platform_interface/src/types/country_with_phone_code.dart'; 2 | 3 | /// Manages countries by code and name 4 | class CountryManager { 5 | factory CountryManager() => _instance; 6 | CountryManager._internal(); 7 | static final CountryManager _instance = CountryManager._internal(); 8 | 9 | var _countries = []; 10 | var _initialized = false; 11 | 12 | /// List of all supported countries on the device with phone code metadata 13 | List get countries => _countries; 14 | 15 | Future loadCountries({ 16 | required final Map phoneCodesMap, 17 | final Map overrides = const {}, 18 | }) async { 19 | if (_initialized) { 20 | return; 21 | } 22 | 23 | try { 24 | /// Apply any overrides to masks / country data 25 | overrides.forEach((final key, final value) { 26 | phoneCodesMap[key] = value; 27 | // print('Applied override for $key'); 28 | }); 29 | 30 | /// Save list of the countries 31 | _countries = phoneCodesMap.values.toList(); 32 | 33 | _initialized = true; 34 | } catch (err) { 35 | _countries = overrides.values.toList(); 36 | // log('[CountryManager] Error loading countries: $err'); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/format_phone_result.dart: -------------------------------------------------------------------------------- 1 | class FormatPhoneResult { 2 | FormatPhoneResult({ 3 | required this.e164, 4 | required this.formattedNumber, 5 | }); 6 | String formattedNumber; 7 | String e164; 8 | 9 | @override 10 | String toString() { 11 | return 'FormatPhoneResult[formattedNumber: $formattedNumber, e164: $e164]'; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/input_formatter.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:math'; 3 | 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 6 | 7 | class LibPhonenumberTextFormatter extends TextInputFormatter { 8 | LibPhonenumberTextFormatter({ 9 | required this.country, 10 | this.phoneNumberType = PhoneNumberType.mobile, 11 | this.phoneNumberFormat = PhoneNumberFormat.international, 12 | this.onFormatFinished, 13 | 14 | /// When true, mask will be applied assuming the input contains 15 | /// a country code in it. 16 | final bool inputContainsCountryCode = false, 17 | 18 | /// Additional digits to include 19 | this.additionalDigits = 0, 20 | 21 | /// Force cursor the end of input when formatting. 22 | this.shouldKeepCursorAtEndOfInput = true, 23 | }) : countryData = CountryManager().countries { 24 | var m = country.getPhoneMask( 25 | format: phoneNumberFormat, 26 | type: phoneNumberType, 27 | removeCountryCodeFromMask: !inputContainsCountryCode, 28 | ); 29 | 30 | /// Allow additional digits on the mask 31 | if (additionalDigits > 0) { 32 | m += List.filled(additionalDigits, '0') 33 | .reduce((final a, final b) => a + b); 34 | } 35 | 36 | _mask = PhoneMask( 37 | mask: m, 38 | country: country, 39 | ); 40 | } 41 | 42 | /// The country to format this number with. 43 | final CountryWithPhoneCode country; 44 | 45 | /// Optionally override the country data. Useful for testing. 46 | List? countryData; 47 | 48 | /// Specify if the number should be formatted as a mobile or land line number. Will default to [PhoneNumberType.mobile] 49 | final PhoneNumberType phoneNumberType; 50 | 51 | /// Specify if the number should be formatted to its national or international pattern. Will default to [PhoneNumberFormat.international] 52 | final PhoneNumberFormat phoneNumberFormat; 53 | 54 | /// Optional function to execute after we are finished formatting the number. 55 | /// Useful if you need to get the formatted value for something else to use. 56 | final FutureOr Function(String val)? onFormatFinished; 57 | 58 | /// Allow additional digits on the end of the mask. This is useful for countries like Austria where the 59 | /// libphonenumber example number doesn't include all of the possibilities. This way we can still format 60 | /// the number but allow additional digits on the end. 61 | final int additionalDigits; 62 | 63 | /// When shouldKeepCursorAtEndOfInput is true, the cursor will be forced to the end of the input after a format happened. Will default to true, 64 | final bool shouldKeepCursorAtEndOfInput; 65 | 66 | late final PhoneMask _mask; 67 | 68 | @override 69 | TextEditingValue formatEditUpdate( 70 | final TextEditingValue oldValue, 71 | final TextEditingValue newValue, 72 | ) { 73 | late final TextEditingValue result; 74 | 75 | /// Apply mask to the input 76 | final newMaskedValue = _mask.apply(newValue.text); 77 | 78 | /// Optionally pass the formatted value to the supplied callback 79 | if (onFormatFinished != null) { 80 | onFormatFinished!.call(newMaskedValue); 81 | } 82 | 83 | // print('>> oldValue: $oldValue\n>> newValue: $newValue\n'); 84 | 85 | /// Force the cursor to the end of the input if requested 86 | if (shouldKeepCursorAtEndOfInput) { 87 | result = TextEditingValue( 88 | selection: TextSelection.collapsed( 89 | offset: newMaskedValue.length, 90 | ), 91 | text: newMaskedValue, 92 | ); 93 | // print('>> result: $result'); 94 | return result; 95 | } 96 | 97 | /// Non-zero if the new input ends with a non-digit value 98 | final match = RegExp(r'\D+$').firstMatch(newValue.text); 99 | final numEndingNonNumbers = match?.group(0)?.length ?? 0; 100 | 101 | if (newValue.text.length > oldValue.text.length) { 102 | /////////////////////////////////// 103 | /// Character(s) added 104 | /// 105 | /// Ex: We typed in a new digit 106 | /// Ex: We pasted in a longer value over an existing selection 107 | /////////////////////////////////// 108 | 109 | // print( 110 | // '>> longer string | oldValue.selection.baseOffset: ${oldValue.selection.baseOffset} | oldValue.text.length: ${oldValue.text.length}'); 111 | 112 | /// We have to account for any new non-digit characters added to the string. 113 | /// Say we have a current value of: "+1 444-867" and we add a new digit (9). 114 | /// newValue is then "+1 444-8679" but newMaskedValue is "+1 444-867-9". 115 | /// The baseOffset in newValue would be off by 1 because the mask added a new dash. 116 | final charsInOld = RegExp(r'(\D)').allMatches(oldValue.text).length; 117 | final charsInNew = RegExp(r'(\D)').allMatches(newMaskedValue).length; 118 | final charsAdded = charsInNew - charsInOld; 119 | 120 | // print('>> charsInOld: $charsInOld | charsInNew = $charsInNew'); 121 | 122 | result = TextEditingValue( 123 | selection: TextSelection.collapsed( 124 | offset: min( 125 | newMaskedValue.length, // don't go more than the end of the string 126 | newValue.selection.baseOffset + charsAdded, 127 | ), 128 | ), 129 | text: newMaskedValue, 130 | ); 131 | // print('>> result: $result'); 132 | return result; 133 | } else if (newValue.text.length < oldValue.text.length) { 134 | /////////////////////////////////// 135 | /// Character(s) removed 136 | /// 137 | /// Ex: We deleted one character with backspace 138 | /// Ex: We pasted a shorter value over an existing selection 139 | /////////////////////////////////// 140 | 141 | // print( 142 | // '>> shorter string | oldValue.selection.baseOffset: ${oldValue.selection.baseOffset} | oldValue.text.length: ${oldValue.text.length}', 143 | // ); 144 | 145 | // print( 146 | // 'oldValue.selection: ${oldValue.selection} | newValue.selection: ${newValue.selection}', 147 | // ); 148 | 149 | if (oldValue.selection.isCollapsed) { 150 | /// A collapsed selection means it's just a cursor with nothing selected. 151 | 152 | // print('>> oldValue.selection.isCollapsed'); 153 | 154 | if (oldValue.selection.baseOffset == oldValue.text.length) { 155 | /// We deleted a character from the end of the string. In that case just put the cursor 156 | /// at the end of the new string. 157 | 158 | // print('>> oldValue.selection.baseOffset == oldValue.text.length'); 159 | 160 | result = TextEditingValue( 161 | selection: TextSelection.collapsed( 162 | offset: newMaskedValue.length, 163 | ), 164 | text: newMaskedValue, 165 | ); 166 | // print('>> result: $result'); 167 | return result; 168 | } else { 169 | /// We deleted a character from somewhere within the string. We have to put the cursor 170 | /// where it was before. 171 | 172 | // print('>> oldValue.selection.baseOffset != oldValue.text.length'); 173 | 174 | result = TextEditingValue( 175 | selection: TextSelection.collapsed( 176 | offset: oldValue.selection.baseOffset - 1, 177 | ), 178 | text: newMaskedValue, 179 | ); 180 | // print('>> result: $result'); 181 | return result; 182 | } 183 | } else { 184 | /// A non-collapsed selection means there's one or more characters selected. 185 | /// We have to put the cursor at the end of the new value inputted. 186 | 187 | // print('>> oldValue.selection.isNotCollapsed'); 188 | 189 | result = TextEditingValue( 190 | selection: TextSelection.collapsed( 191 | offset: newValue.selection.baseOffset - numEndingNonNumbers, 192 | ), 193 | text: newMaskedValue, 194 | ); 195 | // print('>> result: $result'); 196 | return result; 197 | } 198 | } else { 199 | /////////////////////////////////// 200 | /// Character(s) replaced 201 | /// 202 | /// In the case length remained the same 203 | /// Can happen if we select and replace part of the string either pasting or typing the value 204 | /// Ex: select 1 character, type a new one 205 | /// Ex: select 3 characters, paste 3 new ones 206 | /////////////////////////////////// 207 | 208 | // print('>> same length string'); 209 | 210 | result = TextEditingValue( 211 | selection: TextSelection.collapsed( 212 | offset: newValue.selection.baseOffset - numEndingNonNumbers, 213 | ), 214 | text: newMaskedValue, 215 | ); 216 | // print('>> result: $result'); 217 | return result; 218 | } 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/phone_mask.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 2 | 3 | class PhoneMask { 4 | PhoneMask({ 5 | required this.mask, 6 | required this.country, 7 | }); 8 | final String mask; 9 | final CountryWithPhoneCode country; 10 | final RegExp _digitRegex = RegExp('[0-9]+'); 11 | 12 | /// Apply the given phone mask to the input string. 13 | String apply(final String inputString) { 14 | /// If mask is empty, return input string 15 | if (mask.isEmpty) { 16 | return inputString; 17 | } 18 | 19 | var cleanedInput = inputString.replaceAll(RegExp(r'\D'), ''); 20 | 21 | /// If phone mask doesn't contain country code but input does, 22 | /// remove the country code from the input 23 | if (!mask.startsWith('+') && inputString.startsWith('+')) { 24 | cleanedInput = 25 | cleanedInput.replaceFirst(RegExp('^${country.phoneCode}'), ''); 26 | } 27 | 28 | final chars = cleanedInput.split(''); 29 | 30 | final result = []; 31 | var index = 0; 32 | for (var i = 0; i < mask.length; i++) { 33 | if (index >= chars.length) { 34 | break; 35 | } 36 | final curChar = chars[index]; 37 | if (mask[i] == '0') { 38 | /// If it's a digit in the mask, add the digit to the output 39 | if (_isDigit(curChar)) { 40 | result.add(curChar); 41 | index++; 42 | } else { 43 | break; 44 | } 45 | } else { 46 | /// Add the non-digit value from the mask to the output 47 | result.add(mask[i]); 48 | } 49 | } 50 | return result.join(); 51 | } 52 | 53 | /// Returns if something is a digit or not 54 | bool _isDigit(final String character) { 55 | if (character.isEmpty || character.length > 1) { 56 | return false; 57 | } 58 | return _digitRegex.stringMatch(character) != null; 59 | } 60 | 61 | @override 62 | String toString() => '[PhoneMask mask: $mask]'; 63 | } 64 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/phone_number_format.dart: -------------------------------------------------------------------------------- 1 | /// Used to format with national or international format 2 | enum PhoneNumberFormat { national, international } 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/lib/src/types/phone_number_type.dart: -------------------------------------------------------------------------------- 1 | /// Used for phone masks to know how to format numbers 2 | enum PhoneNumberType { mobile, fixedLine } 3 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_platform_interface 2 | description: A common platform interface for the flutter_libphonenumber plugin. 3 | repository: https://github.com/bottlepay/flutter_libphonenumber/tree/main/packages/flutter_libphonenumber_platform_interface 4 | issue_tracker: https://github.com/bottlepay/flutter_libphonenumber/issues 5 | version: 2.1.0 6 | 7 | environment: 8 | sdk: ">=2.19.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | plugin_platform_interface: ^2.1.4 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_platform_interface/test/flutter_libphonenumber_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_libphonenumber_platform_interface/src/types/country_manager.dart'; 2 | import 'package:flutter_libphonenumber_platform_interface/src/types/country_with_phone_code.dart'; 3 | import 'package:flutter_libphonenumber_platform_interface/src/types/input_formatter.dart'; 4 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_mask.dart'; 5 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_number_format.dart'; 6 | import 'package:flutter_libphonenumber_platform_interface/src/types/phone_number_type.dart'; 7 | import 'package:flutter_test/flutter_test.dart'; 8 | 9 | void main() { 10 | group('PhoneMask', () { 11 | test('UK mobile international', () { 12 | final mask = PhoneMask( 13 | mask: const CountryWithPhoneCode.gb().getPhoneMask( 14 | format: PhoneNumberFormat.international, 15 | type: PhoneNumberType.mobile, 16 | ), 17 | country: const CountryWithPhoneCode.gb(), 18 | ); 19 | expect(mask.apply('+447752555555'), '+44 7752 555555'); 20 | }); 21 | 22 | test('Italian mobile international', () { 23 | final mask = PhoneMask( 24 | mask: '+00 000 000 0000', 25 | country: CountryWithPhoneCode( 26 | phoneCode: '+39', 27 | countryCode: '', 28 | exampleNumberMobileNational: '', 29 | exampleNumberFixedLineNational: '', 30 | phoneMaskMobileNational: '', 31 | phoneMaskFixedLineNational: '', 32 | exampleNumberMobileInternational: '', 33 | exampleNumberFixedLineInternational: '', 34 | phoneMaskMobileInternational: '', 35 | phoneMaskFixedLineInternational: '', 36 | countryName: '', 37 | ), 38 | ); 39 | expect(mask.apply('+393937224790'), '+39 393 722 4790'); 40 | }); 41 | 42 | group('getCountryDataByPhone', () { 43 | test('US number', () async { 44 | await CountryManager().loadCountries( 45 | phoneCodesMap: {}, 46 | overrides: {'US': const CountryWithPhoneCode.us()}, 47 | ); 48 | 49 | final res = CountryWithPhoneCode.getCountryDataByPhone('+14194444444'); 50 | expect(res?.countryCode, 'US'); 51 | }); 52 | }); 53 | }); 54 | 55 | group('getPhoneMask', () { 56 | test('with removeCountryCodeFromMask=false', () async { 57 | final res = const CountryWithPhoneCode.us().getPhoneMask( 58 | format: PhoneNumberFormat.international, 59 | type: PhoneNumberType.mobile, 60 | removeCountryCodeFromMask: false, 61 | ); 62 | 63 | expect( 64 | res, 65 | '+0 000-000-0000', 66 | reason: 'mask should contain country code in it', 67 | ); 68 | }); 69 | 70 | test('with removeCountryCodeFromMask=true', () async { 71 | final res = const CountryWithPhoneCode.us().getPhoneMask( 72 | format: PhoneNumberFormat.international, 73 | type: PhoneNumberType.mobile, 74 | removeCountryCodeFromMask: true, 75 | ); 76 | 77 | expect( 78 | res, 79 | '000-000-0000', 80 | reason: 'mask should not contain country code in it', 81 | ); 82 | }); 83 | 84 | test( 85 | 'with phoneNumberFormat=PhoneNumberFormat.national and phoneNumberType=PhoneNumberType.mobile', 86 | () async { 87 | final res = PhoneMask( 88 | mask: const CountryWithPhoneCode.us().getPhoneMask( 89 | format: PhoneNumberFormat.national, 90 | type: PhoneNumberType.mobile, 91 | ), 92 | country: const CountryWithPhoneCode.us(), 93 | ); 94 | final applied = res.apply('+14194444444'); 95 | 96 | expect( 97 | applied, 98 | '(419) 444-4444', 99 | reason: 'mask should not contain country code in it', 100 | ); 101 | }); 102 | 103 | test( 104 | 'with phoneNumberFormat=PhoneNumberFormat.international and phoneNumberType=PhoneNumberType.mobile', 105 | () async { 106 | final res = PhoneMask( 107 | mask: const CountryWithPhoneCode.us().getPhoneMask( 108 | format: PhoneNumberFormat.international, 109 | type: PhoneNumberType.mobile, 110 | ), 111 | country: const CountryWithPhoneCode.us(), 112 | ); 113 | final applied = res.apply('+14194444444'); 114 | 115 | expect( 116 | applied, 117 | '+1 419-444-4444', 118 | reason: 'mask should not contain country code in it', 119 | ); 120 | }); 121 | }); 122 | 123 | group('LibPhonenumberTextFormatter', () { 124 | test('with inputContainsCountryCode=true', () { 125 | final formatter = LibPhonenumberTextFormatter( 126 | country: const CountryWithPhoneCode.us(), 127 | inputContainsCountryCode: true, 128 | ); 129 | 130 | final formatResult = formatter.formatEditUpdate( 131 | TextEditingValue.empty, 132 | const TextEditingValue(text: '+14194444444'), 133 | ); 134 | 135 | expect( 136 | formatResult.text, 137 | '+1 419-444-4444', 138 | reason: 139 | 'formatting with a country code should apply the mask with the country code in it', 140 | ); 141 | }); 142 | 143 | test('with inputContainsCountryCode=false', () { 144 | final formatter = LibPhonenumberTextFormatter( 145 | country: const CountryWithPhoneCode.us(), 146 | inputContainsCountryCode: false, 147 | ); 148 | 149 | final formatResult = formatter.formatEditUpdate( 150 | TextEditingValue.empty, 151 | const TextEditingValue(text: '4194444444'), 152 | ); 153 | 154 | expect( 155 | formatResult.text, 156 | '419-444-4444', 157 | reason: 158 | 'formatting with a country code should apply the mask with the country code in it', 159 | ); 160 | }); 161 | }); 162 | } 163 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 8 | channel: stable 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 17 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 18 | - platform: web 19 | create_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 20 | base_revision: 90c64ed42ba53a52d18f0cb3b17666c8662ed2a0 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.3.0] - 2024.09.19 2 | 3 | - Bump flutter_libphonenumber_platform_interface to 2.1.0 4 | 5 | ## [1.2.0] - 2024.09.18 6 | 7 | - Bump flutter_libphonenumber_platform_interface to 2.0.0 8 | 9 | ## 1.1.0 10 | 11 | - Migrates away from `js` package to support wasm. [#72](https://github.com/acoutts/flutter_libphonenumber/pull/72) 12 | 13 | ## 1.0.1 14 | 15 | - Bump JS package. 16 | 17 | ## 1.0.0 18 | 19 | - Initial implementation by laynor. 20 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bottlepay Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_web 2 | 3 | Web platform implementation for `flutter_libphonenumber`. 4 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_libphonenumber_web_example 2 | 3 | Demonstrates how to use the flutter_libphonenumber_web plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_web_example 2 | description: Demonstrates how to use the flutter_libphonenumber_web plugin. 3 | publish_to: none 4 | 5 | environment: 6 | sdk: ">=3.3.0 <4.0.0" 7 | flutter: ">=3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | flutter_libphonenumber_web: 14 | path: ../ 15 | flutter_libphonenumber_platform_interface: ^2.1.0 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | flutter: 22 | uses-material-design: true 23 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_web/example/web/favicon.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_web/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_web/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_web/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acoutts/flutter_libphonenumber/9b17bf2d138a465d0affdfdc293bcf491101c977/packages/flutter_libphonenumber_web/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | flutter_libphonenumber_web_example 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_libphonenumber_web_example", 3 | "short_name": "flutter_libphonenumber_web_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Demonstrates how to use the flutter_libphonenumber_web plugin.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/lib/flutter_libphonenumber_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:js_interop'; 2 | 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_libphonenumber_platform_interface/flutter_libphonenumber_platform_interface.dart'; 5 | import 'package:flutter_libphonenumber_web/src/base.dart'; 6 | import 'package:flutter_libphonenumber_web/src/libphonenumber.dart' 7 | as phoneutil; 8 | import 'package:flutter_libphonenumber_web/src/utils.dart'; 9 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 10 | import 'package:web/web.dart'; 11 | 12 | /// The version of libphonenumber to use 13 | const String libPhoneNumberVersion = 'b7fe84af9b553f0f2db765a6e20c27fa867a971d'; 14 | const String libPhoneNumberUrl = 15 | 'https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@$libPhoneNumberVersion/dist/libphonenumber.min.js'; 16 | 17 | class FlutterLibphonenumberPlugin extends FlutterLibphonenumberPlatform { 18 | static late Future _jsLibrariesLoadingFuture; 19 | 20 | /// Registers this class as the default instance of [FlutterLibphonenumberPlatform]. 21 | static void registerWith(final Registrar registrar) { 22 | FlutterLibphonenumberPlatform.instance = FlutterLibphonenumberPlugin(); 23 | _setupScripts(); 24 | } 25 | 26 | static void _setupScripts() { 27 | final libraries = [ 28 | const JsLibrary( 29 | contextName: 'libphonenumber', 30 | url: libPhoneNumberUrl, 31 | usesRequireJs: true, 32 | ), 33 | ]; 34 | 35 | final helperScriptTag = HTMLScriptElement() 36 | ..type = 'application/javascript' 37 | ..text = ''' 38 | function libPhoneNumberFlutterGetRegionDisplayNames(lang) { 39 | return new Intl.DisplayNames([lang], {type: 'region'}); 40 | } 41 | '''; 42 | 43 | document.head!.append(helperScriptTag); 44 | _jsLibrariesLoadingFuture = injectJSLibraries(libraries); 45 | } 46 | 47 | @override 48 | Future> format( 49 | final String phone, 50 | final String region, 51 | ) async { 52 | await _jsLibrariesLoadingFuture; 53 | 54 | try { 55 | final formatter = phoneutil.AsYouTypeFormatter(region); 56 | formatter.clear(); 57 | String formatted = ''; 58 | for (final char in phone.split('')) { 59 | formatted = formatter.inputDigit(char); 60 | } 61 | return {'formatted': formatted}; 62 | } catch (_) { 63 | throw PlatformException( 64 | code: 'InvalidNumber', 65 | message: 'Number $phone is invalid', 66 | ); 67 | } 68 | } 69 | 70 | @override 71 | Future> getAllSupportedRegions() async { 72 | await _jsLibrariesLoadingFuture; 73 | 74 | final util = phoneutil.PhoneNumberUtil.getInstance(); 75 | 76 | final res = {}; 77 | 78 | final displayNames = phoneutil 79 | .libPhoneNumberFlutterGetRegionDisplayNames(window.navigator.language); 80 | 81 | final regions = util.getSupportedRegions().toDart; 82 | for (final regionJs in regions) { 83 | final region = regionJs.toDart; 84 | final exampleNumberMobile = util.getExampleNumberForType( 85 | region, 86 | phoneutil.PhoneNumberType.MOBILE, 87 | ) ?? 88 | phoneutil.PhoneNumber(); 89 | 90 | final exampleNumberFixedLine = util.getExampleNumberForType( 91 | region, 92 | phoneutil.PhoneNumberType.FIXED_LINE, 93 | ) ?? 94 | phoneutil.PhoneNumber(); 95 | 96 | final phoneCode = util.getCountryCodeForRegion(region).toString(); 97 | 98 | res[region] = CountryWithPhoneCode( 99 | phoneCode: phoneCode, 100 | countryCode: region, 101 | exampleNumberMobileNational: _formatNational(exampleNumberMobile), 102 | exampleNumberFixedLineNational: _formatNational(exampleNumberFixedLine), 103 | phoneMaskMobileNational: _maskNumber( 104 | _formatNational(exampleNumberMobile), 105 | phoneCode, 106 | ), 107 | phoneMaskFixedLineNational: _maskNumber( 108 | _formatNational(exampleNumberFixedLine), 109 | phoneCode, 110 | ), 111 | exampleNumberMobileInternational: 112 | _formatInternational(exampleNumberMobile), 113 | exampleNumberFixedLineInternational: 114 | _formatInternational(exampleNumberFixedLine), 115 | phoneMaskMobileInternational: _maskNumber( 116 | _formatInternational(exampleNumberMobile), 117 | phoneCode, 118 | ), 119 | phoneMaskFixedLineInternational: _maskNumber( 120 | _formatInternational(exampleNumberFixedLine), 121 | phoneCode, 122 | ), 123 | countryName: displayNames.of(region), 124 | ); 125 | } 126 | return res; 127 | } 128 | 129 | @override 130 | Future> parse( 131 | final String phone, { 132 | final String? region, 133 | }) async { 134 | await _jsLibrariesLoadingFuture; 135 | 136 | final util = phoneutil.PhoneNumberUtil.getInstance(); 137 | final res = util.parseStringAndRegion(phone, region); 138 | if (res != null) { 139 | return res; 140 | } else { 141 | throw PlatformException( 142 | code: 'InvalidNumber', 143 | message: 'Number $phone is invalid', 144 | ); 145 | } 146 | } 147 | 148 | @override 149 | Future init({ 150 | final Map overrides = const {}, 151 | }) async { 152 | await _jsLibrariesLoadingFuture; 153 | 154 | return CountryManager().loadCountries( 155 | phoneCodesMap: await getAllSupportedRegions(), 156 | overrides: overrides, 157 | ); 158 | } 159 | 160 | static String _maskNumber(final String phoneNumber, final String phoneCode) => 161 | phoneNumber.replaceAll(RegExp(r'\d'), '0'); 162 | 163 | static String _formatNational(final phoneutil.PhoneNumber phoneNumber) => 164 | phoneutil.PhoneNumberUtil.getInstance() 165 | .format(phoneNumber, phoneutil.PhoneNumberFormat.NATIONAL); 166 | 167 | static String _formatInternational(final phoneutil.PhoneNumber phoneNumber) => 168 | phoneutil.PhoneNumberUtil.getInstance().format( 169 | phoneNumber, 170 | phoneutil.PhoneNumberFormat.INTERNATIONAL, 171 | ); 172 | } 173 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/lib/src/base.dart: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License 2 | 3 | // Copyright (c) 2022, Julian Steenbakker 4 | // All rights reserved. 5 | 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | 9 | // 1. Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | 16 | // 3. Neither the name of the copyright holder nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | class JsLibrary { 32 | const JsLibrary({ 33 | required this.contextName, 34 | required this.url, 35 | required this.usesRequireJs, 36 | }); 37 | 38 | /// The name of global variable where library is stored. 39 | /// Used to properly import the library if [usesRequireJs] flag is true 40 | final String contextName; 41 | final String url; 42 | 43 | /// If js code checks for 'define' variable. 44 | /// E.g. if at the beginning you see code like 45 | /// if (typeof define === "function" && define.amd) 46 | final bool usesRequireJs; 47 | } 48 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/lib/src/libphonenumber.dart: -------------------------------------------------------------------------------- 1 | @JS() 2 | library libphonenumber; 3 | 4 | import 'dart:js_interop'; 5 | 6 | @JS() 7 | external DisplayNames libPhoneNumberFlutterGetRegionDisplayNames( 8 | final String lang, 9 | ); 10 | 11 | @JS('Intl.DisplayNames') 12 | extension type DisplayNames._(JSObject _) implements JSObject { 13 | external String of(final String countryCode); 14 | } 15 | 16 | @JS('libphonenumber.PhoneNumber') 17 | extension type PhoneNumber._(JSObject _) implements JSObject { 18 | external PhoneNumber(); 19 | external int getCountryCode(); 20 | external int getNationalNumber(); 21 | } 22 | 23 | @JS('libphonenumber.PhoneNumberFormat') 24 | extension type PhoneNumberFormat._(JSObject _) implements JSObject { 25 | external static int E164; 26 | external static int INTERNATIONAL; 27 | external static int NATIONAL; 28 | external static int RFC3966; 29 | } 30 | 31 | @JS('libphonenumber.PhoneNumberType') 32 | extension type PhoneNumberType._(JSObject _) implements JSObject { 33 | external static int FIXED_LINE; 34 | external static int MOBILE; 35 | external static int FIXED_LINE_OR_MOBILE; 36 | external static int TOLL_FREE; 37 | external static int PREMIUM_RATE; 38 | external static int SHARED_COST; 39 | external static int VOIP; 40 | external static int PERSONAL_NUMBER; 41 | external static int PAGER; 42 | external static int UAN; 43 | external static int VOICEMAIL; 44 | external static int UNKNOWN; 45 | } 46 | 47 | String numberTypeToString(final int type) { 48 | switch (type) { 49 | case 0: 50 | return 'fixedLine'; 51 | case 1: 52 | return 'mobile'; 53 | case 2: 54 | return 'fixedOrMobile'; 55 | case 3: 56 | return 'tollFree'; 57 | case 4: 58 | return 'premiumRate'; 59 | case 5: 60 | return 'sharedCost'; 61 | case 6: 62 | return 'voip'; 63 | case 7: 64 | return 'personalNumber'; 65 | case 8: 66 | return 'pager'; 67 | case 9: 68 | return 'uan'; 69 | case 10: 70 | return 'voiceMail'; 71 | case -1: 72 | return 'unknown'; 73 | default: 74 | return 'notParsed'; 75 | } 76 | } 77 | 78 | @JS('libphonenumber.AsYouTypeFormatter') 79 | extension type AsYouTypeFormatter._(JSObject _) implements JSObject { 80 | external AsYouTypeFormatter(final String? regionCode); 81 | external void clear(); 82 | external String inputDigit(final String char); 83 | } 84 | 85 | @JS('libphonenumber.PhoneNumberUtil') 86 | extension type PhoneNumberUtil._(JSObject _) implements JSObject { 87 | external static PhoneNumberUtil getInstance(); 88 | external JSObject getExampleNumber(final String regionCode); 89 | external PhoneNumber parse( 90 | final String phoneNumber, 91 | final String? regionCode, 92 | ); 93 | external bool isValidNumber(final PhoneNumber phoneNumber); 94 | external int getNumberType(final PhoneNumber phoneNumber); 95 | external String format( 96 | final PhoneNumber phoneNumber, 97 | final int phoneNumberFormat, 98 | ); 99 | external String getRegionCodeForNumber(final PhoneNumber phoneNumber); 100 | external JSArray getSupportedRegions(); 101 | external int getCountryCodeForRegion(final String? region); 102 | external PhoneNumber? getExampleNumberForType( 103 | final String region, 104 | final int type, 105 | ); 106 | } 107 | 108 | extension PhoneNumberUtilExt on PhoneNumberUtil { 109 | Map? parseStringAndRegion( 110 | final String phone, 111 | final String? region, 112 | ) { 113 | try { 114 | final phoneNumber = parse(phone, region); 115 | if (!isValidNumber(phoneNumber)) { 116 | return null; 117 | } else { 118 | return { 119 | 'type': numberTypeToString(getNumberType(phoneNumber)), 120 | 'e164': format(phoneNumber, PhoneNumberFormat.E164), 121 | 'international': format(phoneNumber, PhoneNumberFormat.INTERNATIONAL), 122 | 'national': format(phoneNumber, PhoneNumberFormat.NATIONAL), 123 | 'country_code': '${phoneNumber.getCountryCode()}', 124 | 'region_code': getRegionCodeForNumber(phoneNumber), 125 | 'national_number': '${phoneNumber.getNationalNumber()}', 126 | }; 127 | } 128 | } catch (e) { 129 | return null; 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License 2 | 3 | // Copyright (c) 2022, Julian Steenbakker 4 | // All rights reserved. 5 | 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | 9 | // 1. Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | 16 | // 3. Neither the name of the copyright holder nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | import 'dart:async'; 32 | 33 | import 'package:flutter_libphonenumber_web/src/base.dart'; 34 | import 'package:web/web.dart'; 35 | 36 | Future loadScript(final JsLibrary library) async { 37 | await loadScriptUsingScriptTag(library.url); 38 | } 39 | 40 | Future loadScriptUsingScriptTag(final String url) { 41 | final script = HTMLScriptElement() 42 | ..async = true 43 | ..defer = false 44 | ..crossOrigin = 'anonymous' 45 | ..type = 'text/javascript' 46 | ..src = url; 47 | 48 | document.head!.append(script); 49 | 50 | return script.onLoad.first; 51 | } 52 | 53 | /// Injects JS [libraries] 54 | /// 55 | /// Returns a [Future] that resolves when all of the `script` tags `onLoad` events trigger. 56 | Future injectJSLibraries(final List libraries) { 57 | final List> loading = []; 58 | 59 | for (final library in libraries) { 60 | final future = loadScript(library); 61 | loading.add(future); 62 | } 63 | 64 | return Future.wait(loading); 65 | } 66 | -------------------------------------------------------------------------------- /packages/flutter_libphonenumber_web/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_web 2 | description: Web implementation of the flutter_libphonenumber plugin. 3 | repository: https://github.com/bottlepay/flutter_libphonenumber/tree/main/packages/flutter_libphonenumber_web 4 | issue_tracker: https://github.com/bottlepay/flutter_libphonenumber/issues 5 | version: 1.3.0 6 | 7 | environment: 8 | sdk: ">=3.3.0 <4.0.0" 9 | flutter: ">=3.0.0" 10 | 11 | flutter: 12 | plugin: 13 | implements: flutter_libphonenumber 14 | platforms: 15 | web: 16 | pluginClass: FlutterLibphonenumberPlugin 17 | fileName: flutter_libphonenumber_web.dart 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | flutter_web_plugins: 23 | sdk: flutter 24 | flutter_libphonenumber_platform_interface: ^2.0.0 25 | 26 | web: ">=0.5.0 <2.0.0" 27 | 28 | dev_dependencies: 29 | flutter_test: 30 | sdk: flutter 31 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_libphonenumber_workspace 2 | description: The workspace containing all of the flutter_libphonenumber packages. 3 | 4 | environment: 5 | sdk: ">=2.19.5 <3.0.0" 6 | 7 | dev_dependencies: 8 | melos: ^3.0.0 9 | --------------------------------------------------------------------------------