account_selector 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

account_selector #

A Flutter package which provides helper widgets for selecting single or multiple account/user from a list

Supported Dart Versions #

Dart SDK version >= 2.1.0

Demo Screen Shots #

Account Selector Demo Custom Account Selector Demo  MultiAccount Selector Demo Custom MultiAccount Selector Demo

Demo Gif #

Account Selector Demo

Installation #

Pub

Add the Package

dependencies:
  account_selector: ^1.0.1

How to use #

Import the package in your dart file

import 'package:account_selector/account.dart';
import 'package:account_selector/account_selector.dart';

Create an account list to provide to custom widgets

List<Account> accountList = [
    Account(
        title: "Bill Gates",
        accountImageWidget: getImage("assets/sample1.jpg")),
    Account(
        title: "Steve Jobs",
        accountImageWidget: getImage("assets/sample2.jpg")),
    Account(
        title: "Mark Elliot Zuckerberg",
        accountImageWidget: getImage("assets/sample3.jpg")),
    Account(
        title: "Sundar Pichai",
        accountImageWidget: getImage("assets/sample4.jpg")),
  ];

   static getImage(String assetPath) {
    return Image.asset(assetPath, fit: BoxFit.cover);
  }

Now to use the Single Account Selection modal sheet call showAccountSelectorSheet as follows :

showAccountSelectorSheet(
                context: context,
                accountList: accountList,
                isSheetDismissible: false,              // Optional
                initiallySelectedIndex: 2,              // Optional
                hideSheetOnItemTap: true,               // Optional
                addAccountTitle: "Add User",            // Optional
                showAddAccountOption: true,             // Optional
                backgroundColor: Colors.indigo,         // Optional
                arrowColor: Colors.white,               // Optional
                unselectedRadioColor: Colors.white,     // Optional
                selectedRadioColor: Colors.amber,       // Optional
                unselectedTextColor: Colors.white,      // Optional
                selectedTextColor: Colors.amber,        // Optional
               //Optional
                tapCallback: (index) {
                  //use the index of item selected to do your work over here
                }, 
                //Optional
                addAccountTapCallback: () {
                 // operation to perform when add account is clicked
                },
              );

For MultiSelection the showMultiAccountSelectorSheet() method return the list of index of the items selected. If the sheet is closed without clicking done then the empty list is returned.

onPressed: () async {
              var res = await showMultiAccountSelectorSheet(
                context: context,
                accountList: accountList,
                initiallySelectedIndexList: [0, 2],         // Optional
                isSheetDismissible: false,                  // Optional
                backgroundColor: Colors.orange[100],        // Optional
                arrowColor: Colors.purple,                  // Optional
                doneButtonColor: Colors.purple,             // Optional
                doneText: "Done",                           // Optional
                checkedIconColor: Colors.purple,            // Optional
                selectedTextColor: Colors.purple,           // Optional
                uncheckedIconColor: Colors.grey[800],       // Optional
                unselectedTextColor: Colors.grey[800],      // Optional
              );
           
              print(res.toString());

Default configuration/styles #

If you don't like to configure/style the modal sheets and continue with the default style, it's okay but just have a look at our default configuration.

For showAccountSelectorSheet

AttributeValue
isSheetDismissibletrue
initiallySelectedIndexif not provided, initially no item will be selected
hideSheetOnItemTapfalse
selectedRadioColorColors.green
tapCallbackby default it will be (val){}, ie it wont do anything
showAddAccountOptionfalse
addAccountTitle"Add Account"
addAccountTapCallbackby default it will be (){}, ie it wont do anything
arrowColorColors.grey
backgroundColorColors.white
selectedTextColorColors.green
unselectedTextColorconst Color(0xFF424242)
unselectedRadioColorColors.grey

For showMultiAccountSelectorSheet

AttributeValue
isSheetDismissibletrue
initiallySelectedIndexListif not provided, initially no item will be selected
doneText"Done"
checkedIconColorColors.green
uncheckedIconColorColors.grey
doneButtonColorColors.blue
arrowColorColors.grey
backgroundColorColors.white
selectedTextColorColors.green
unselectedTextColorconst Color(0xFF424242)

Pull Requests #

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.) This is best achieved using Reformat Code feature of Android Studio CMD+Option+L on Mac and CTRL + ALT + L on Linux + Windows .
  2. If its a feature, bugfix, or anything please only change code to what you specify.
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
  4. Pull requests must be made against develop branch. Any other branch (unless specified by the maintainers) will get rejected.
  5. Check for existing issues first, before filing an issue.
  6. Make sure you follow the set standard as all other projects in this repo do
  7. Have fun!

Created & Maintained By #

Harpreet Singh

License #

Copyright 2020 Harpreet Singh

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

[1.0.1] - Release #

  • Fixed Health issues

[1.0.0] - Release #

  • Fixed maintenance issues

[0.0.2] - Release #

  • Fixed Health issues

[0.0.1] - Release #

  • Customizable account selection modal bottom sheet widgets
  • Account Selection with add account option
  • Multiple Account Selection option

example/lib/main.dart

import 'package:flutter/material.dart';

import 'home_screen.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomeScreenWidget(),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  account_selector: ^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_selector/account_selector.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • account_selector that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.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