user_country_detector_android 0.0.1 copy "user_country_detector_android: ^0.0.1" to clipboard
user_country_detector_android: ^0.0.1 copied to clipboard

PlatformAndroid

User country detector. Android only.

example/lib/main.dart

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

import 'package:user_country_detector_android/user_country_detector_android.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  Future<(String, bool)> get future => Future(() async {
    final nci = await UserCountryDetectorAndroid.getCountryIso3166Alpha2();
    final sup = await UserCountryDetectorAndroid.isSupported;
    return (nci, sup);
  });

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        floatingActionButton: FloatingActionButton(onPressed: () {
          setState(() {

          });
        }),
        body: Center(
          child: FutureBuilder(
            future: future,
            builder: (context, snapshot) {
              if (snapshot.connectionState != ConnectionState.done) {
                return CircularProgressIndicator();
              }

              if (snapshot.hasError) {
                return Text('${snapshot.error}');
              }

              return Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Text('Country code: ${snapshot.data!.$1}'),
                  Text('Supports detector: ${snapshot.data!.$2}'),
                ],
              );
            },
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
44
downloads

Publisher

unverified uploader

Weekly Downloads

User country detector. Android only.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on user_country_detector_android

Packages that implement user_country_detector_android