Merge remote-tracking branch 'origin/main'

# Conflicts:
#	CHANGELOG.md
#	example/lib/main.dart
#	example/pubspec.yaml
#	ios/Flutter/Generated.xcconfig
#	ios/Flutter/flutter_export_environment.sh
#	pubspec.yaml
This commit is contained in:
Nilashish Roy
2024-12-11 20:48:33 +06:00
13 changed files with 343 additions and 1138 deletions

View File

@@ -1,15 +1,11 @@
## 3.0.1 - May 5 2024
- Support Flutter 3.22.1
- Added Header Text
## 3.1.0 - October 24 2024
- Add some improvement
## 3.0.0 - March 10 2023
- Support Flutter 3.7.0
- Restructured package follow linter
## 2.0.2
- added localization for no_country text in italian and english (please open a pr with other languages if you know them 🙏)
- added possibility to inject a custom list of countries using `CountryCodePicker.countryList`
- minor fixes

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
</component>
</module>

View File

@@ -2,12 +2,11 @@ import 'package:country_code_picker/country_code_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() => runApp( const MyApp());
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
MyAppState createState() => MyAppState();
}
@@ -108,10 +107,12 @@ class MyAppState extends State<MyApp> {
favorite: const ['+39', 'FR'],
countryFilter: const ['IT', 'FR'],
showFlagDialog: false,
//You can set the margin between the flag and the country name to your taste.
margin: const EdgeInsets.symmetric(horizontal: 6),
comparator: (a, b) => b.name!.compareTo(a.name!),
//Get the country information relevant to the initial selection
onInit: (code) => debugPrint(
"on init ${code!.name} ${code.dialCode} ${code.name}"),
"on init ${code?.name} ${code?.dialCode} ${code?.name}"),
),
CountryCodePicker(
onChanged: print,

View File

@@ -11,7 +11,7 @@ version: 1.0.0+1
publish_to: none
environment:
sdk: '>=3.3.0 <4.0.0'
sdk: '>=2.17.0 <4.0.0'
dependencies:
flutter:

View File

@@ -1,14 +0,0 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=C:\src\flutter
FLUTTER_APPLICATION_PATH=C:\Users\RAHMAN\StudioProjects\CountryCodePicker
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib\main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=3.0.0
FLUTTER_BUILD_NUMBER=3.0.0
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
EXCLUDED_ARCHS[sdk=iphoneos*]=armv7
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json

View File

@@ -1,13 +0,0 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\src\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\RAHMAN\StudioProjects\CountryCodePicker"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=3.0.0"
export "FLUTTER_BUILD_NUMBER=3.0.0"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"

View File

@@ -1,19 +0,0 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end
NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */

View File

@@ -1,14 +0,0 @@
//
// Generated file. Do not edit.
//
// clang-format off
#import "GeneratedPluginRegistrant.h"
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
}
@end

View File

@@ -19,6 +19,7 @@ class CountryCodePicker extends StatefulWidget {
final List<String> favorite;
final TextStyle? textStyle;
final EdgeInsetsGeometry padding;
final EdgeInsetsGeometry? margin;
final bool showCountryOnly;
final InputDecoration searchDecoration;
final TextStyle? searchStyle;
@@ -99,6 +100,7 @@ class CountryCodePicker extends StatefulWidget {
this.favorite = const [],
this.textStyle,
this.padding = const EdgeInsets.all(8.0),
this.margin,
this.showCountryOnly = false,
this.searchDecoration = const InputDecoration(),
this.searchStyle,
@@ -127,7 +129,8 @@ class CountryCodePicker extends StatefulWidget {
this.dialogBackgroundColor,
this.closeIcon = const Icon(Icons.close),
this.countryList = codes,
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
this.dialogItemPadding =
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
Key? key,
}) : super(key: key);
@@ -194,9 +197,10 @@ class CountryCodePickerState extends State<CountryCodePicker> {
? Clip.none
: Clip.hardEdge,
decoration: widget.flagDecoration,
margin: widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0),
margin: widget.margin ??
(widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0)),
child: Image.asset(
selectedItem!.flagUri!,
package: 'country_code_picker',
@@ -221,9 +225,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
flex: widget.alignLeft ? 0 : 1,
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
child: Padding(
padding: widget.alignLeft
padding: (widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0),
: const EdgeInsets.only(right: 16.0)),
child: Icon(
Icons.arrow_drop_down,
color: Colors.grey,

View File

@@ -1,5 +1,6 @@
import 'package:collection/collection.dart' show IterableExtension;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'country_codes.dart';
import 'country_localizations.dart';
@@ -39,6 +40,15 @@ class CountryCode {
return CountryCode.fromJson(jsonCode!);
}
static CountryCode? tryFromCountryCode(String countryCode) {
try {
return CountryCode.fromCountryCode(countryCode);
} catch (e) {
if (kDebugMode) print('Failed to recognize country from countryCode: $countryCode');
return null;
}
}
factory CountryCode.fromDialCode(String dialCode) {
final Map<String, String>? jsonCode = codes.firstWhereOrNull(
(code) => code['dial_code'] == dialCode,
@@ -46,6 +56,15 @@ class CountryCode {
return CountryCode.fromJson(jsonCode!);
}
static CountryCode? tryFromDialCode(String dialCode) {
try {
return CountryCode.fromDialCode(dialCode);
} catch (e) {
if (kDebugMode) print('Failed to recognize country from dialCode: $dialCode');
return null;
}
}
CountryCode localize(BuildContext context) {
return this
..name = CountryLocalizations.of(context)?.translate(code) ?? name;

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,12 @@
name: country_code_picker
description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox
version: 3.0.0
version: 3.1.0
homepage: https://github.com/chandrabezzo/CountryCodePicker
repository: https://github.com/chandrabezzo/CountryCodePicker
issue_tracker: https://github.com/imtoori/CountryCodePicker/issues
environment:
sdk: '>=3.4.1 <4.0.0'
flutter: ">=1.17.0"
sdk: '>=2.17.0 <4.0.0'
dependencies:
flutter: