device_region 1.4.0 copy "device_region: ^1.4.0" to clipboard
device_region: ^1.4.0 copied to clipboard

This plugin uses platform-specific API to return SIM country code

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:device_region/device_region.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _simRegion = 'Unknown';

  Future<void> askForSIMCountryCode() async {
    final result = await DeviceRegion.getSIMCountryCode();

    setState(() => _simRegion = result ?? 'Can\'t receive country code');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Device_region example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: askForSIMCountryCode,
                child: const Text('Get SIM country code'),
              ),
              const SizedBox(height: 15),
              Text('Your SIM country code is: $_simRegion\n'),
            ],
          ),
        ),
      ),
    );
  }
}
21
likes
160
points
5.3k
downloads

Publisher

verified publishermatszafraniec.xyz

Weekly Downloads

This plugin uses platform-specific API to return SIM country code

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on device_region