Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Adding fixed id to every country #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/country_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ class CountryCode {
/// the dial code (+39,+93..)
final String? dialCode;

/// fixed id for countries you might be add it from the server
final String? id;
CountryCode({
this.name,
this.flagUri,
this.code,
this.dialCode,
this.id,
});

@Deprecated('Use `fromCountryCode` instead.')
Expand All @@ -50,14 +53,14 @@ class CountryCode {

CountryCode localize(BuildContext context) {
return this
..name =
CountryLocalizations.of(context)?.translate(this.code) ?? this.name;
..name = CountryLocalizations.of(context)?.translate(this.code) ?? this.name;
}

factory CountryCode.fromJson(Map<String, dynamic> json) {
return CountryCode(
name: json['name'],
code: json['code'],
id: json['id'],
dialCode: json['dial_code'],
flagUri: 'flags/${json['code'].toLowerCase()}.png',
);
Expand Down
2 changes: 0 additions & 2 deletions lib/country_code_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import 'package:collection/collection.dart' show IterableExtension;
import 'package:country_code_picker/country_code.dart';
import 'package:country_code_picker/country_codes.dart';
import 'package:country_code_picker/selection_dialog.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:universal_platform/universal_platform.dart';

export 'country_code.dart';

class CountryCodePicker extends StatefulWidget {
Expand Down