sim_card_code 0.0.5
sim_card_code: ^0.0.5 copied to clipboard
A Flutter plugin for accessing SIM card and getting Phone number Country Code.
Sim Card Info Plugin #
A comprehensive Flutter plugin that provides extensive access to SIM card and network information across iOS and Android platforms. Get detailed information about SIM cards, network operators, device identifiers, and dual SIM support.
📋 Features #
SIM Card Information #
- Country Code: Retrieve SIM card country code in ISO format (e.g., "US", "UK", "IN")
- Operator Details: Get SIM operator name and operator code
- Serial Number: Access SIM card serial number (ICCID)
- Phone Number: Retrieve the phone number associated with the SIM
- SIM State: Check current SIM card state (READY, ABSENT, PIN_REQUIRED, etc.)
- SIM Presence: Detect if a SIM card is present in the device
Network Information #
- Network Operator: Get current network operator name
- Network Country: Retrieve network country code
- Network Type: Identify network technology (LTE, 5G, HSPA, EDGE, etc.)
- Roaming Status: Check if device is currently roaming
Dual SIM Support #
- SIM Count: Get total number of SIM slots
- Dual SIM Detection: Check if device supports dual SIM
- All SIM Info: Retrieve detailed information for all active SIM cards
- Multi-SIM Management: Handle multiple subscriptions and SIM slots
Device Information #
- Device ID: Get device IMEI/MEID identifier
🔧 Installation #
Add sim_card_code
to your pubspec.yaml
:
dependencies:
sim_card_code: ^latest_version
Then run:
flutter pub get
📱 Platform Support #
Platform | Support |
---|---|
Android | ✅ |
iOS (9.0+) | ✅ |
Web | ❌ |
macOS | ❌ |
Windows | ❌ |
Linux | ❌ |
🔐 Permissions #
Android #
Add the following permission to your android/app/src/main/AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
iOS #
No additional setup required for iOS 9.0 - 13.x.
🚀 Usage #
Import the package:
import 'package:sim_card_code/sim_card_code.dart';
Basic SIM Information #
// Get SIM country code
try {
final countryCode = await SimCardManager.simCountryCode;
} catch (e) {
print('Error: $e');
}
// Get SIM operator name
try {
final operatorName = await SimCardManager.simOperatorName;
print('SIM Operator: $operatorName'); // Output: "Verizon", "Vodafone", etc.
} catch (e) {
print('Error: $e');
}
// Get SIM operator code
try {
final operatorCode = await SimCardManager.simOperatorCode;
print('Operator Code: $operatorCode'); // Output: "310260", etc.
} catch (e) {
print('Error: $e');
}
SIM State and Presence #
// Check if SIM card is present
try {
final hasSimCard = await SimCardManager.hasSimCard;
print('Has SIM Card: $hasSimCard');
} catch (e) {
print('Error: $e');
}
// Get SIM state
try {
final simState = await SimCardManager.simState;
print('SIM State: $simState'); // READY, ABSENT, PIN_REQUIRED, etc.
} catch (e) {
print('Error: $e');
}
Network Information #
// Get network operator name
try {
final networkOperator = await SimCardManager.networkOperatorName;
print('Network Operator: $networkOperator');
} catch (e) {
print('Error: $e');
}
// Get network country code
try {
final networkCountryCode = await SimCardManager.networkCountryCode;
print('Network Country Code: $networkCountryCode');
} catch (e) {
print('Error: $e');
}
// Get network type
try {
final networkType = await SimCardManager.networkType;
print('Network Type: $networkType'); // LTE, HSPA, EDGE, etc.
} catch (e) {
print('Error: $e');
}
// Check roaming status
try {
final isRoaming = await SimCardManager.isRoaming;
print('Is Roaming: $isRoaming');
} catch (e) {
print('Error: $e');
}
Dual SIM Support #
// Check if device supports dual SIM
try {
final isDualSim = await SimCardManager.isDualSim;
print('Is Dual SIM: $isDualSim');
} catch (e) {
print('Error: $e');
}
// Get SIM count
try {
final simCount = await SimCardManager.simCount;
print('SIM Count: $simCount');
} catch (e) {
print('Error: $e');
}
// Get all SIM information
try {
final allSimInfo = await SimCardManager.getAllSimInfo;
for (var simInfo in allSimInfo) {
print('Slot Index: ${simInfo['slotIndex']}');
print('Subscription ID: ${simInfo['subscriptionId']}');
print('Display Name: ${simInfo['displayName']}');
print('Carrier Name: ${simInfo['carrierName']}');
print('Country ISO: ${simInfo['countryIso']}');
print('Phone Number: ${simInfo['phoneNumber']}');
print('Is Roaming: ${simInfo['isNetworkRoaming']}');
print('---');
}
} catch (e) {
print('Error: $e');
}
Sensitive Information (Requires Permissions) #
// Get SIM serial number (ICCID)
try {
final serialNumber = await SimCardManager.simSerialNumber;
print('SIM Serial Number: $serialNumber');
} catch (e) {
print('Error: $e');
}
// Get phone number
try {
final phoneNumber = await SimCardManager.phoneNumber;
print('Phone Number: $phoneNumber');
} catch (e) {
print('Error: $e');
}
// Get device ID (IMEI/MEID)
try {
final deviceId = await SimCardManager.deviceId;
print('Device ID: $deviceId');
} catch (e) {
print('Error: $e');
}
📊 SIM States #
The plugin returns the following SIM states:
READY
: SIM card is ready for useABSENT
: No SIM card detectedPIN_REQUIRED
: SIM card requires PIN entryPUK_REQUIRED
: SIM card requires PUK entryNETWORK_LOCKED
: SIM card is network lockedNOT_READY
: SIM card is not readyPERM_DISABLED
: SIM card is permanently disabledCARD_IO_ERROR
: SIM card I/O errorCARD_RESTRICTED
: SIM card is restrictedUNKNOWN
: Unknown SIM state
🌐 Network Types #
The plugin identifies the following network types:
LTE
: 4G LTE networkHSPA
: High Speed Packet AccessHSDPA
: High Speed Downlink Packet AccessHSUPA
: High Speed Uplink Packet AccessHSPAP
: Evolved High Speed Packet AccessUMTS
: Universal Mobile Telecommunications SystemEDGE
: Enhanced Data rates for GSM EvolutionGPRS
: General Packet Radio ServiceCDMA
: Code Division Multiple AccessEVDO_0
: Evolution-Data Optimized Rev 0EVDO_A
: Evolution-Data Optimized Rev A1xRTT
: Single Carrier Radio Transmission TechnologyEHRPD
: Evolved High Rate Packet DataUNKNOWN
: Unknown network type
⚠️ Error Handling #
The plugin returns null
in the following cases:
- No SIM card is detected
- The device doesn't support the requested functionality
- Required permissions are not granted
- Any other error occurs during execution
All methods may throw exceptions with specific error codes:
PERMISSION_DENIED
: Required permissions not grantedSIM_*_ERROR
: Specific SIM-related errorsNETWORK_*_ERROR
: Network-related errors
🔒 Privacy Considerations #
This plugin accesses sensitive device and SIM information. Some methods require the READ_PHONE_STATE
permission and may return personally identifiable information such as:
- Phone numbers
- Device IMEI/MEID
- SIM serial numbers
Ensure you comply with your app store's privacy policies and inform users about data collection.
💖 Support #
If you find this plugin helpful, consider supporting the development:
🤝 Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
📞 Contact #
For bugs or feature requests, please create an issue on the GitHub repository.
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.