86 lines
2.0 KiB
Dart
86 lines
2.0 KiB
Dart
|
// simParameters.dart
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:sim_data/sim_data.dart';
|
||
|
import 'package:permission_handler/permission_handler.dart';
|
||
|
|
||
|
class SimParametersPage extends StatefulWidget {
|
||
|
const SimParametersPage({super.key});
|
||
|
|
||
|
@override
|
||
|
_SimParametersPageState createState() => _SimParametersPageState();
|
||
|
}
|
||
|
|
||
|
class _SimParametersPageState extends State<SimParametersPage> {
|
||
|
List<SimCard> _simCards = [];
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
_fetchSimParameters();
|
||
|
}
|
||
|
|
||
|
Future<void> _fetchSimParameters() async {
|
||
|
if (await Permission.phone.request().isGranted) {
|
||
|
try {
|
||
|
final simData = await SimDataPlugin.getSimData();
|
||
|
setState(() {
|
||
|
_simCards = simData.cards;
|
||
|
});
|
||
|
} catch (e) {
|
||
|
// Handle error
|
||
|
print('Error fetching SIM data: $e');
|
||
|
}
|
||
|
} else {
|
||
|
// Permission denied
|
||
|
print('Phone permission denied');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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(
|
||
|
'''
|
||
|
Opérateur: ${sim.carrierName}
|
||
|
Pays: ${sim.countryCode ?? 'N/A'}
|
||
|
MCC: ${sim.mcc ?? 'N/A'}
|
||
|
MNC: ${sim.mnc ?? 'N/A'}
|
||
|
Slot Index: ${sim.slotIndex ?? 'N/A'}
|
||
|
Display Name: ${sim.displayName ?? 'N/A'}
|
||
|
''',
|
||
|
style: const TextStyle(color: Colors.grey),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
backgroundColor: Colors.black,
|
||
|
appBar: AppBar(
|
||
|
title: const Text('Paramètre SIM'),
|
||
|
),
|
||
|
body: _simCards.isEmpty
|
||
|
? const Center(
|
||
|
child: Text(
|
||
|
'Aucune carte SIM trouvée',
|
||
|
style: TextStyle(color: Colors.white),
|
||
|
),
|
||
|
)
|
||
|
: ListView.builder(
|
||
|
itemCount: _simCards.length,
|
||
|
itemBuilder: (context, index) {
|
||
|
return _buildSimInfo(_simCards[index], index);
|
||
|
},
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|