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

Overview

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

Attribute Value
isSheetDismissible true
initiallySelectedIndex if not provided, initially no item will be selected
hideSheetOnItemTap false
selectedRadioColor Colors.green
tapCallback by default it will be (val){}, ie it wont do anything
showAddAccountOption false
addAccountTitle "Add Account"
addAccountTapCallback by default it will be (){}, ie it wont do anything
arrowColor Colors.grey
backgroundColor Colors.white
selectedTextColor Colors.green
unselectedTextColor const Color(0xFF424242)
unselectedRadioColor Colors.grey

For showMultiAccountSelectorSheet

Attribute Value
isSheetDismissible true
initiallySelectedIndexList if not provided, initially no item will be selected
doneText "Done"
checkedIconColor Colors.green
uncheckedIconColor Colors.grey
doneButtonColor Colors.blue
arrowColor Colors.grey
backgroundColor Colors.white
selectedTextColor Colors.green
unselectedTextColor const 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.
You might also like...

Custom widgets and utils using Flutter framework widgets and Dart language

reuse_widgets_and_utils The custom widgets and utils using Flutter framework widgets and Dart programming language. Getting Started This project is a

Oct 29, 2021

Widgets beginner - Widgets beginner with flutter

Widgets beginner - Widgets beginner with flutter

Widgets beginner - Widgets beginner with flutter

Feb 6, 2022

This flutter package provides an easy implementation of a Slider Button to cancel current transaction or screen

This flutter package provides an easy implementation of a Slider Button to cancel current transaction or screen

This flutter package provides an easy implementation of a Slider Button to cancel current transaction or screen

Nov 8, 2022

A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

Sep 7, 2022

A highly customizable multiple selection widget with search functionality.

A highly customizable multiple selection widget with search functionality.

A highly customizable multiple selection widget with search functionality.

Dec 19, 2022

A flutter package to select a country from a list of countries.

A flutter package to select a country from a list of countries.

Country picker A flutter package to select a country from a list of countries. Getting Started Add the package to your pubspec.yaml: country_picker: ^

Dec 30, 2022

Flutter UI Widgets Flutter Package

Flutter UI Widgets Flutter Package This package makes different Flutter UI widgets implementation easy for you. Flutter UI Widgets The list of widgets

May 6, 2022

Flutter Package for Easier Creation of Home Screen Widgets

Flutter Package for Easier Creation of Home Screen Widgets

Home Widget HomeWidget is a Plugin to make it easier to create HomeScreen Widgets on Android and iOS. HomeWidget does not allow writing Widgets with F

Dec 31, 2022

A new flutter package for collection of common popular social media widgets

A new flutter package for collection of common popular social media widgets

Social Media Widgets - package A new flutter package for collection of common popular social media widgets Currently available widgets Snapchat screen

Nov 12, 2022
Owner
Harpreet Singh
Flutter Developer
Harpreet Singh
A flutter package which provides most commonly used widgets with their normal and neon version

This is a flutter package which provides most commonly used widgets with their normal and neon version. There are multiple different types of widgets under this package, which can be used to create more neon theme widget

ojas 24 Oct 7, 2022
A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents.

Sliding Sheet A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. Click here to view the full example. Ins

null 396 Mar 10, 2022
A widget to provides horizontal or vertical multiple split view for Flutter.

Multi split view A widget to provides horizontal or vertical multiple split view for Flutter. Horizontal or vertical Configurable weight or size for e

Carlos Eduardo Leite de Andrade 63 Dec 28, 2022
Flutter debug helper widget with common and custom actions

Flutter debug helper widget with common and custom actions

Stanislav Ilin 43 Dec 7, 2022
Similar to Weibo dynamics, WeChat circle of friends, nine grid view controls to display pictures. Support single big picture preview.

Similar to Weibo dynamics, WeChat circle of friends, nine grid view controls to display pictures. Support single big picture preview.

Flutter中国开源项目 296 Dec 28, 2022
Flutter package: Assorted layout widgets that boldly go where no native Flutter widgets have gone before.

assorted_layout_widgets I will slowly but surely add interesting widgets, classes and methods to this package. Despite the package name, they are not

Marcelo Glasberg 122 Dec 22, 2022
A flutter plugin which provides Crop Widget for cropping images.

A flutter plugin which provides Crop Widget for cropping images.

Chooyan 97 Jan 5, 2023
A custom Slider which accepts a list of ordered values.

MultiSlider A custom Slider which accepts a list of ordered values. It's meant to be as simple as the original Slider! UI with it Usages Continuous sl

Sthefano Schiavon 7 Dec 3, 2022
Build a grouped list, which support expand/collapse section and sticky headers, support use it with sliver widget.

sticky_and_expandable_list Flutter implementation of sticky headers and expandable list.Support use it in a CustomScrollView. README i18n:中文说明 Feature

tp7309 114 Nov 16, 2022
Flutter-useful-widgets - Flutter Useful Widgets

useful_widgets This package makes it easy to build apps by providing a list of simple and useful widgets. import 'package:useful_widgets/useful_widget

Ricardo Crescenti 6 Jun 20, 2022