carrier_info_wp 1.0.1 copy "carrier_info_wp: ^1.0.1" to clipboard
carrier_info_wp: ^1.0.1 copied to clipboard

Simple carrier info plugin

example/lib/main.dart

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

import 'package:carrier_info_wp/carrier_info_wp.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  CarrierData? carrierData;
  final _carrierInfoWp = CarrierInfoWp();

  @override
  void initState() {
    super.initState();

    /// TO avoid calling 'setState' method during build method
    WidgetsBinding.instance.addPostFrameCallback((_) {
      loadInfo();
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> loadInfo() async {
    final info = await _carrierInfoWp.getInfo();

    setState(() {
      carrierData = info;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Carrier info wp example app'),
        ),
        body: Center(
          child: Column(
            children: [
              if (carrierData != null) ...[
                Text('Carrier name : ${carrierData?.carrierName}'),
                const SizedBox(
                  height: 16,
                ),
                Text('Iso country code : ${carrierData?.isoCountryCode}')
              ],
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
150
points
301
downloads

Publisher

unverified uploader

Weekly Downloads

Simple carrier info plugin

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on carrier_info_wp