How to Change Default Country Code
This guide explains how to set and manage the default country code for phone number login in your eDemand application. There are two ways to configure this:
- Through the Admin Panel (Recommended)
- Through Code Configuration (Backup)
1. Admin Panel Configuration
The easiest way to set the default country code is through the admin panel:
- Log in to your Admin Panel
- Navigate to Settings > General Settings
- Find the Country Code Settings section
- Add your desired country code
- Click Save to apply changes
Figure 1: Country Code Settings in Admin Panel
This is the recommended method as it allows you to change the country code without modifying the code.
2. Code-Side Configuration (Backup)
If there are any issues with the API or admin panel settings, the app will fall back to the code-side configuration. This serves as a backup to ensure the app always has a valid country code.
Location
The default country code is defined in:
lib/utils/constant.dart
How to Modify
- Open
lib/utils/constant.dart
- Find the country code constant
- Update the value to your desired country code
Figure 2: Default Country Code Configuration in constant.dart
Example:
// Default country code constant
const String defaultCountryCode = 'IN'; // Change this to your desired country code
The code-side configuration serves as a fallback. The admin panel settings will take precedence when available.
Best Practices
-
Always set through Admin Panel first
- This is the recommended approach
- Changes can be made without code deployment
- Easier to manage and update
-
Keep code-side configuration as backup
- Ensures app functionality even if API fails
- Should match your most common user base
- Update only when absolutely necessary
-
Testing
- After changing the country code, test the login flow
- Verify both admin panel and code-side configurations
- Check if the changes reflect correctly in the app
Troubleshooting
If you encounter issues with country code settings:
- Check if the admin panel settings are saved correctly
- Verify the API is responding with the correct country code
- If issues persist, the app will fall back to the code-side configuration
- Clear app cache and restart if changes don't reflect immediately