0.0.1: Initial commit
This commit is contained in:
parent
1af350780d
commit
e8cd30aefe
7 changed files with 447 additions and 0 deletions
75
.gitignore
vendored
Normal file
75
.gitignore
vendored
Normal file
|
@ -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
|
10
.metadata
Normal file
10
.metadata
Normal file
|
@ -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: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
|
||||
channel: stable
|
||||
|
||||
project_type: package
|
4
CHANGELOG.md
Normal file
4
CHANGELOG.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
## [0.0.1] - April 12, 2020
|
||||
|
||||
* Add CheckboxListTileFormField
|
||||
* Add CheckboxIconFormField
|
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# checkbox_formfield
|
||||
|
||||
A few kinds of checkbox that can be used as FormField
|
||||
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Dart
|
||||
[package](https://flutter.dev/developing-packages/),
|
||||
a library module containing code that can be shared easily across
|
||||
multiple Flutter or Dart projects.
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
104
lib/checkbox_formfield.dart
Normal file
104
lib/checkbox_formfield.dart
Normal file
|
@ -0,0 +1,104 @@
|
|||
library checkbox_formfield;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CheckboxListTileFormField extends FormField<bool> {
|
||||
CheckboxListTileFormField({
|
||||
Key key,
|
||||
Widget title,
|
||||
BuildContext context,
|
||||
FormFieldSetter<bool> onSaved,
|
||||
FormFieldValidator<bool> validator,
|
||||
bool initialValue = false,
|
||||
bool autovalidate = false,
|
||||
bool enabled = true,
|
||||
bool dense = false,
|
||||
Color activeColor,
|
||||
Color checkColor = const Color(0xFFFFFFFF),
|
||||
ListTileControlAffinity listTileControlAffinity =
|
||||
ListTileControlAffinity.leading,
|
||||
Widget secondary,
|
||||
}) : super(
|
||||
key: key,
|
||||
onSaved: onSaved,
|
||||
validator: validator,
|
||||
initialValue: initialValue,
|
||||
autovalidate: autovalidate,
|
||||
builder: (FormFieldState<bool> state) {
|
||||
return CheckboxListTile(
|
||||
title: title,
|
||||
dense: dense,
|
||||
// if active color is null, Theme.of(context).accentColor will be used.
|
||||
activeColor: activeColor,
|
||||
checkColor: checkColor,
|
||||
value: state.value,
|
||||
onChanged: enabled ? state.didChange : null,
|
||||
subtitle: state.hasError
|
||||
? Text(
|
||||
state.errorText,
|
||||
style: context == null
|
||||
? TextStyle(color: Colors.red)
|
||||
: TextStyle(color: Theme.of(context).errorColor),
|
||||
)
|
||||
: null,
|
||||
controlAffinity: listTileControlAffinity,
|
||||
secondary: secondary,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class CheckboxIconFormField extends FormField<bool> {
|
||||
CheckboxIconFormField({
|
||||
Key key,
|
||||
BuildContext context,
|
||||
FormFieldSetter<bool> onSaved,
|
||||
//FormFieldValidator<bool> validator,
|
||||
bool initialValue = false,
|
||||
bool autovalidate = false,
|
||||
bool enabled = true,
|
||||
IconData trueIcon = Icons.check,
|
||||
Color trueIconColor,
|
||||
IconData falseIcon = Icons.check_box_outline_blank,
|
||||
Color falseIconColor,
|
||||
double padding = 24.0,
|
||||
double iconSize = 24.0,
|
||||
}) : super(
|
||||
key: key,
|
||||
onSaved: onSaved,
|
||||
//validator: validator,
|
||||
initialValue: initialValue,
|
||||
autovalidate: autovalidate,
|
||||
builder: (FormFieldState<bool> state) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(padding),
|
||||
child: _createTappableIcon(state, trueIcon, trueIconColor,
|
||||
falseIcon, falseIconColor, iconSize),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
static Widget _createTappableIcon(
|
||||
FormFieldState<bool> state,
|
||||
IconData trueIcon,
|
||||
Color trueIconColor,
|
||||
IconData falseIcon,
|
||||
Color falseIconColor,
|
||||
double iconSize) {
|
||||
if (state.value) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
state.didChange(false);
|
||||
},
|
||||
child: Icon(trueIcon, color: trueIconColor, size: iconSize),
|
||||
);
|
||||
} else {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
state.didChange(true);
|
||||
},
|
||||
child: Icon(falseIcon, color: falseIconColor, size: iconSize),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
188
pubspec.lock
Normal file
188
pubspec.lock
Normal file
|
@ -0,0 +1,188 @@
|
|||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.11"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.11"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0+1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.5"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.11"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.5.0"
|
||||
sdks:
|
||||
dart: ">=2.4.0 <3.0.0"
|
52
pubspec.yaml
Normal file
52
pubspec.yaml
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: checkbox_formfield
|
||||
description: A few kinds of checkbox that can be used as FormField
|
||||
version: 0.0.1
|
||||
homepage: https://reidha.github.io/
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# To add assets to your package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# To add custom fonts to your package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.dev/custom-fonts/#from-packages
|
Loading…
Reference in a new issue