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

@@ -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