sim_card_code 0.0.4
sim_card_code: ^0.0.4 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 SimCardInfo.simCountryCode;
print('SIM Country Code: $countryCode'); // Output: "US", "GB", etc.
} catch (e) {
print('Error: $e');
}
// Get SIM operator name
try {
final operatorName = await SimCardInfo.simOperatorName;
print('SIM Operator: $operatorName'); // Output: "Verizon", "Vodafone", etc.
} catch (e) {
print('Error: $e');
}
// Get SIM operator code
try {
final operatorCode = await SimCardInfo.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 SimCardInfo.hasSimCard;
print('Has SIM Card: $hasSimCard');
} catch (e) {
print('Error: $e');
}
// Get SIM state
try {
final simState = await SimCardInfo.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 SimCardInfo.networkOperatorName;
print('Network Operator: $networkOperator');
} catch (e) {
print('Error: $e');
}
// Get network country code
try {
final networkCountryCode = await SimCardInfo.networkCountryCode;
print('Network Country Code: $networkCountryCode');
} catch (e) {
print('Error: $e');
}
// Get network type
try {
final networkType = await SimCardInfo.networkType;
print('Network Type: $networkType'); // LTE, HSPA, EDGE, etc.
} catch (e) {
print('Error: $e');
}
// Check roaming status
try {
final isRoaming = await SimCardInfo.isRoaming;
print('Is Roaming: $isRoaming');
} catch (e) {
print('Error: $e');
}
Dual SIM Support #
// Check if device supports dual SIM
try {
final isDualSim = await SimCardInfo.isDualSim;
print('Is Dual SIM: $isDualSim');
} catch (e) {
print('Error: $e');
}
// Get SIM count
try {
final simCount = await SimCardInfo.simCount;
print('SIM Count: $simCount');
} catch (e) {
print('Error: $e');
}
// Get all SIM information
try {
final allSimInfo = await SimCardInfo.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 SimCardInfo.simSerialNumber;
print('SIM Serial Number: $serialNumber');
} catch (e) {
print('Error: $e');
}
// Get phone number
try {
final phoneNumber = await SimCardInfo.phoneNumber;
print('Phone Number: $phoneNumber');
} catch (e) {
print('Error: $e');
}
// Get device ID (IMEI/MEID)
try {
final deviceId = await SimCardInfo.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.