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

100 lines
3.5 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/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/form_field_controller.dart';
class CustomSelect extends StatefulWidget {
final List<String> options;
final List<String> optionsLabel;
final String hintText;
final FormFieldController<String>? controller;
const CustomSelect({
Key? key,
required this.options,
required this.optionsLabel,
required this.hintText,
this.controller,
}) : super(key: key);
@override
_CustomSelectState createState() => _CustomSelectState();
}
class _CustomSelectState extends State<CustomSelect> {
late FormFieldController<String> _controller;
@override
void initState() {
super.initState();
_controller = widget.controller ?? FormFieldController<String>(null);
}
@override
Widget build(BuildContext 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).secondaryBackground,
controller: _controller,
options: widget.options,
optionLabels: widget.optionsLabel,
onChanged: (val) {
setState(() => _controller.value = val);
},
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),
),
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,
isMultiSelect: false,
),
),
),
),
],
),
],
),
);
}
}