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

How to set font size of text label and hint ? #23

Open
vpaul9678 opened this issue Jun 4, 2021 · 0 comments
Open

How to set font size of text label and hint ? #23

vpaul9678 opened this issue Jun 4, 2021 · 0 comments

Comments

@vpaul9678
Copy link

`library dropdown_formfield;

import 'package:flutter/material.dart';

class DropDownFormField extends FormField {
final String titleText;
final String hintText;
final bool required;
final String errorText;
final dynamic value;
final List dataSource;
final String textField;
final String valueField;
final Function onChanged;
final bool filled;
final EdgeInsets contentPadding;

DropDownFormField(
{FormFieldSetter onSaved,
FormFieldValidator validator,
bool autovalidate = false,
this.titleText = 'Title',
this.hintText = 'Select one option',
this.required = false,
this.errorText = 'Please select one option',
this.value,
this.dataSource,
this.textField,
this.valueField,
this.onChanged,
this.filled = true,
this.contentPadding = const EdgeInsets.fromLTRB(12, 12, 8, 0)})
: super(
onSaved: onSaved,
validator: validator,
autovalidate: autovalidate,
initialValue: value == '' ? null : value,
builder: (FormFieldState state) {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InputDecorator(

                decoration: InputDecoration(
                  contentPadding: contentPadding,
                  labelText: titleText,
                  filled: filled,
                ),
                child: DropdownButtonHideUnderline(
                  child: DropdownButton<dynamic>(
                    isExpanded: true,
                    hint: Text(
                      hintText,
                      style: TextStyle(color: Colors.grey.shade500),
                    ),
                    value: value == '' ? null : value,
                    onChanged: (dynamic newValue) {
                      state.didChange(newValue);
                      onChanged(newValue);
                    },
                    items: dataSource.map((item) {
                      return DropdownMenuItem<dynamic>(
                        value: item[valueField],
                        child: Text(item[textField],
                            overflow: TextOverflow.ellipsis),
                      );
                    }).toList(),
                  ),
                ),
              ),
              SizedBox(height: state.hasError ? 5.0 : 0.0),
              Text(
                state.hasError ? state.errorText : '',
                style: TextStyle(
                    color: Colors.redAccent.shade700,
                    fontSize: state.hasError ? 12.0 : 0.0),
              ),
            ],
          ),
        );
      },
    );

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant