Skip to content

CountrySelectorNavigator does not respect the order of favorite countries #25

@Sikorrr

Description

@Sikorrr

The CountrySelectorNavigator widget does not display the favorite countries in the specified order, even when sortCountries: false is set. According to the documentation, favorite countries should always appear in the order they are provided in the favorites parameter, regardless of the sortCountries setting. However, they are displayed in alphabetical order instead.

Reproduction Steps
The issue can be reproduced using the following minimal code:

import 'package:flutter/material.dart';
import 'package:phone_form_field/phone_form_field.dart';

class TestCountrySelector extends StatelessWidget {
  const TestCountrySelector({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PhoneFormField(
        countrySelectorNavigator: const CountrySelectorNavigator.page(
          favorites: [IsoCode.FR, IsoCode.GB, IsoCode.DE],
          sortCountries: false,
        ),
        initialValue: const PhoneNumber(isoCode: IsoCode.GB, nsn: ''),
        decoration: const InputDecoration(labelText: 'Phone Number'),
      ),
    );
  }
}

Observed Behavior
When running the example above, the favorite countries are displayed in alphabetical order (FR, DE, GB) instead of the specified order (FR, GB, DE).

Expected Behavior
The favorite countries should appear in the exact order provided in the favorites parameter. In this case, the expected order is [FR, GB, DE].

Environment
Flutter Version: Flutter 3.24.5 • channel stable
phone_form_field Version: 10.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions