-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca877a9
Showing
9 changed files
with
918 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
build/ | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Flutter.podspec | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/Flutter/flutter_export_environment.sh | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: b041144f833e05cf463b8887fa12efdec9493488 | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.0.1] - 2020-06-20 | ||
### Added | ||
- Creation of MultiSelect package | ||
- Widgets include with MultiSelectListDialog, MultiSelectChipDialog, MultiSelectChipDisplay, | ||
MultiSelectField, MultiSelectFormField. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) 2020, Christiaan H. Botha | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Flutter Multi Select | ||
|
||
Flutter Multi Select is a package for easily creating multi-select widgets in a variety of ways. | ||
|
||
<img src="https://i.imgur.com/Tl7VjCc.gif" alt="drawing" width="200"/> | ||
| ||
<img src="https://i.imgur.com/7ME7xZ5.gif" alt="drawing" width="200"/> | ||
|
||
## Installation | ||
|
||
Add to dependency in pubspec.yaml | ||
|
||
```bash | ||
dependencies: | ||
flutter-multi-select 0.0.1 | ||
``` | ||
|
||
## Usage | ||
|
||
#### MultiSelectListDialog / MultiSelectChipDialog | ||
|
||
These widgets can be used in the builder of showDialog(). | ||
|
||
```javascript | ||
void _showMultiSelectDialog(BuildContext context) async { | ||
_selectedItems = await showDialog( | ||
context: context, | ||
builder: (ctx) { | ||
return MultiSelectListDialog<int>( | ||
items: _Items.map((item) => | ||
MultiSelectItem(item, item.name)).toList(), | ||
title: "Dialog Title", | ||
initialSelectedItems: _selectedItems, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
``` | ||
#### MultiSelectChipDisplay | ||
This widget can be used by itself, alongside one of the dialogs, or it can be specified as a parameter of *MultiSelectField / MultiSelectFormField*. | ||
|
||
To use this widget effectively, make sure to set the state when the list of items is changed. | ||
|
||
You can also remove items from the source list in the onTap function. | ||
|
||
``` | ||
MultiSelectChipDisplay( | ||
items: _selectedItems.map((item) => | ||
MultiSelectItem(item, item.name)).toList(), | ||
onTap: (item) { | ||
setState(() { | ||
_selectedItems.remove(item); | ||
}); | ||
}, | ||
), | ||
``` | ||
#### MultiSelectField | ||
*MultiSelectField* provides a button which opens the dialog. | ||
To save the values from the dialog using this widget, an **onConfirm(values)** function is provided. | ||
|
||
``` | ||
MultiSelectField( | ||
title: "Animals", | ||
buttonText: "Favorite Animals" | ||
items: dialogItems, | ||
dialogType: MultiSelectDialogType.CHIP, | ||
decoration: BoxDecoration( | ||
color: Theme.of(context).primaryColor.withOpacity(.4), | ||
border: Border.all( | ||
color: Theme.of(context).primaryColor, | ||
), | ||
), | ||
textStyle: TextStyle(fontSize: 20), | ||
onConfirm: (results) { | ||
setState(() { | ||
_selectedAnimals = results; | ||
}); | ||
}, | ||
), | ||
``` | ||
|
||
#### MultiSelectFormField | ||
*MultiSelectFormField* is the FormField version of *MultiSelectField*. You can put it into a form and make use of FormField methods such as validate() and onSave(). | ||
|
||
It also comes with a default bottom-border that can be overriden with the **decoration** parameter. | ||
|
||
``` | ||
Form( | ||
key: _formKey, | ||
child: MultiSelectFormField( | ||
buttonIcon: Icon(Icons.arrow_forward_ios), | ||
validator: (value) { | ||
if (value == null || value.isEmpty) { | ||
return "Required"; | ||
} | ||
return null; | ||
}, | ||
onSaved: (value) { | ||
_selectedAnimals = value; | ||
}, | ||
title: "Animals", | ||
items: items, | ||
dialogType: MultiSelectDialogType.CHIP, | ||
onConfirm: (values) { | ||
_formKey.currentState.validate(); | ||
}, | ||
chipDisplay: MultiSelectChipDisplay( | ||
items: _selectedAnimalItems, | ||
), | ||
), | ||
), | ||
``` | ||
|
||
## Contributing | ||
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. | ||
|
||
## License | ||
[MIT](https://choosealicense.com/licenses/mit/) |
Oops, something went wrong.