flutter-freaccess-hub/lib/components/atomic_components/shared_components_atoms/custom_select.dart

129 lines
4.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/flutter_flow/flutter_flow_drop_down.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/shared/utils/limited_text_size.dart';
// ignore: must_be_immutable
class CustomSelect extends StatefulWidget {
final List<String> options;
final List<String> optionsLabel;
final String hintText;
final bool isMultiSelect;
FormFieldController<String> controller;
dynamic Function(String?)? changed;
String? dropDownValue;
bool isRequired;
CustomSelect({
super.key,
required this.options,
required this.optionsLabel,
required this.hintText,
required this.controller,
required this.changed,
this.isRequired = false,
this.dropDownValue,
this.isMultiSelect = false,
});
@override
_CustomSelectState createState() => _CustomSelectState();
}
class _CustomSelectState extends State<CustomSelect> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
double limitedInputFontSize = LimitedFontSizeUtil.getInputFontSize(context);
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0, 0.0, 0, 10.0),
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
child: Container(
width: 100.0,
height: 48.0,
decoration: const BoxDecoration(),
child: FlutterFlowDropDown<String>(
fillColor: FlutterFlowTheme.of(context).primaryBackground,
controller: widget.controller,
options: widget.options,
optionLabels: widget.optionsLabel,
onChanged: widget.changed,
isMultiSelect: false,
width: double.infinity,
height: double.infinity,
textStyle: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
letterSpacing: 0.0,
useGoogleFonts:
GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily),
fontSize: limitedInputFontSize,
),
hintText: widget.hintText,
icon: Icon(
Icons.keyboard_arrow_down_rounded,
color: FlutterFlowTheme.of(context).accent1,
size: 24.0,
),
elevation: 2.0,
borderColor: FlutterFlowTheme.of(context).customColor6,
borderWidth: 0.5,
borderRadius: 10.0,
margin: const EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 16.0, 0.0),
hidesUnderline: true,
isOverButton: true,
isSearchable: false,
),
),
),
),
],
),
if (widget.isRequired)
if (widget.dropDownValue == null || widget.dropDownValue == '')
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(top: 5, start: 15),
child: Text(
FFLocalizations.of(context).getVariableText(
enText: 'This field is required',
ptText: 'Este campo é obrigatório',
),
style: FlutterFlowTheme.of(context).bodySmall.override(
fontFamily: FlutterFlowTheme.of(context).bodySmallFamily,
color: FlutterFlowTheme.of(context).customColor6,
letterSpacing: 0.0,
useGoogleFonts:
GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodySmallFamily),
fontSize: limitedInputFontSize
)),
),
],
),
),
],
),
);
}
}