account_picker 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

Account Picker Plugin #

This Flutter plugin prompt suser to pick an Email or a Phone number saved on device without requiring extra permission It is a lightweight plugin that does not require extra permssion. This plugin does not require any special device permission.

It uses AccountPicker API.

This currently works for Android only.

Demo App

Usage to request Phone #

final String phone = await AccountPicker.phoneHint();
setState(() {
    _phoneNumber = phone;
});

Usage to request Email #

final EmailResult emailResult = await AccountPicker.emailHint();
print(emailResult);
setState(() {
    _email = emailResult.email;
    _accountType = emailResult.type;
});

TODO #

Implement the Ios method channel

[1.0.1] - 12th June 2020. #

  • Fixed RegisterWith was not adding onActivityResult listner
  • Changed Activity Result intent Code to reduce risk of plugin conflict

[1.0.0] - 11th June 2020. #

  • Initial Release.

example/lib/main.dart

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

import 'package:flutter/services.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _email;
  String _accountType;
  String _phoneNumber;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await AccountPicker.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              Text('Running on: $_platformVersion\n'),
              Text('Email: $_email'),
              Text('Email Type: $_accountType'),
              Text('Phone Number: $_phoneNumber'),
              RaisedButton(
                onPressed: () async {
                  final String phone = await AccountPicker.phoneHint();
                  setState(() {
                    _phoneNumber = phone;
                  });
                },
                child: Text('Pick Phone'),
              ),
              RaisedButton(
                onPressed: () async {
                  final EmailResult emailResult = await AccountPicker.emailHint();
                  print(emailResult);
                  setState(() {
                    _email = emailResult.email;
                    _accountType = emailResult.type;
                  });
                },
                child: Text('Pick Email'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  account_picker: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:account_picker/account_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:account_picker/account_picker.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:account_picker/account_picker.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:account_picker/account_picker.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:account_picker/account_picker.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • account_picker that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

9 out of 9 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/account_picker.dart.

Run flutter format to format lib/account_picker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test