Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more props #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DS_Store
.dart_tool/

.vscode/
.fvm/

.packages
.pub/

Expand Down
15 changes: 15 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\Aaron\Documents\ProyectosPersonales\dropdown_formfield\example"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
39 changes: 20 additions & 19 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety.3"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -80,21 +80,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.8"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,55 +106,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.5"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.17"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.17.0"
41 changes: 38 additions & 3 deletions lib/dropdown_formfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,52 @@ library dropdown_formfield;
import 'package:flutter/material.dart';

class DropDownFormField extends FormField<dynamic> {
/// String value to indicate widget title
final String titleText;

/// String value to indicate hint text
final String hintText;

/// Boolean value to indicate when the widget value is required
final bool required;

/// String value to indicate error text
final String errorText;

/// Dynamic value to indicate the initial value for the widget
final dynamic value;

/// Dynamic list of values to fill the dropdown list
final List dataSource;

/// String value to indicate the field to display from dataSource
final String textField;

/// String value to indicate the field to take as value from dataSource
final String valueField;

/// Function to call when the dropdown changes its value
final Function onChanged;

/// Boolean value to indicate when input is filled by default color
final bool filled;

/// Color value to indicate the fill color when filled is true
final Color filledColor;

/// Value to stylize the title label
final TextStyle labelStyle;

/// Value to stylize the hint text
final TextStyle hintStyle;

/// Value to indicate the content padding
final EdgeInsets contentPadding;

DropDownFormField(
{FormFieldSetter<dynamic> onSaved,
FormFieldValidator<dynamic> validator,
bool autovalidate = false,
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
this.titleText = 'Title',
this.hintText = 'Select one option',
this.required = false,
Expand All @@ -29,11 +59,14 @@ class DropDownFormField extends FormField<dynamic> {
this.valueField,
this.onChanged,
this.filled = true,
this.filledColor = const Color.fromARGB(255, 237, 237, 238),
this.labelStyle,
this.hintStyle,
this.contentPadding = const EdgeInsets.fromLTRB(12, 12, 8, 0)})
: super(
onSaved: onSaved,
validator: validator,
autovalidate: autovalidate,
autovalidateMode: autovalidateMode,
initialValue: value == '' ? null : value,
builder: (FormFieldState<dynamic> state) {
return Container(
Expand All @@ -44,14 +77,16 @@ class DropDownFormField extends FormField<dynamic> {
decoration: InputDecoration(
contentPadding: contentPadding,
labelText: titleText,
labelStyle: labelStyle,
filled: filled,
fillColor: filledColor
),
child: DropdownButtonHideUnderline(
child: DropdownButton<dynamic>(
isExpanded: true,
hint: Text(
hintText,
style: TextStyle(color: Colors.grey.shade500),
style: hintStyle??TextStyle(color: Colors.grey.shade500),
),
value: value == '' ? null : value,
onChanged: (dynamic newValue) {
Expand Down
Loading