import 'package:flutter/material.dart'; import 'package:mobile_number/mobile_number.dart'; class SimParametersPage extends StatefulWidget { const SimParametersPage({Key? key}) : super(key: key); @override _SimParametersPageState createState() => _SimParametersPageState(); } class _SimParametersPageState extends State { List _simCards = []; @override void initState() { super.initState(); _fetchSimParameters(); } Future _fetchSimParameters() async { try { bool permissionsGranted = await MobileNumber.hasPhonePermission; if (!permissionsGranted) { await MobileNumber.requestPhonePermission; // Check again if permission is granted permissionsGranted = await MobileNumber.hasPhonePermission; } if (permissionsGranted) { List? simCards = await MobileNumber.getSimCards; if (simCards != null && mounted) { setState(() { _simCards = simCards; }); } else { print('No SIM cards found'); } } else { print('Phone permission denied'); } } catch (e) { print('Failed to get SIM cards: $e'); } } Widget _buildSimInfo(SimCard sim, int index) { return Card( color: Colors.grey[850], child: ListTile( title: Text( 'SIM ${index + 1}', style: const TextStyle(color: Colors.white), ), subtitle: Text( ''' Carrier Name: ${sim.carrierName ?? 'N/A'} Country Iso: ${sim.countryIso ?? 'N/A'} Display Name: ${sim.displayName ?? 'N/A'} Slot Index: ${sim.slotIndex ?? 'N/A'} Number: ${sim.number ?? 'N/A'} ''', style: const TextStyle(color: Colors.grey), ), ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( title: const Text('SIM Parameters'), ), body: _simCards.isEmpty ? const Center( child: Text( 'No SIM cards found', style: TextStyle(color: Colors.white), ), ) : ListView.builder( itemCount: _simCards.length, itemBuilder: (context, index) { return _buildSimInfo(_simCards[index], index); }, ), ); } }