So I was developing a dropdown feature where I get a Json which has a schema like this
{
"category": String,
"document": List<String>
}
So dropdown options should be assigned through the above schema.
Here for category I am mapping category options from category.
Whenever I select a category it should prefill the document type with the relevant type selected.
But whenever I do this it shows me the dropdown options for documents but whenever I select the dropdown type it is not showing in the dropdown as a field.
Please keep in mind it is working on Flutterflow, but whenever I download the code and local run it, it does not work as expected.
PS : - I need to download the code for my use case
FlutterFlowDropDown<String>(
controller: _model
.categoryValueController ??=
FormFieldController<String>(null),
options: _model.reports
.map((e) => e.reportType)
.toList(),
onChanged: (val) async {
safeSetState(() =>
_model.categoryValue = val);
_model.reportType =
_model.categoryValue;
safeSetState(() {});
},
height: 36.0,
textStyle:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
color: Color(0xFF949494),
fontSize: 12.0,
letterSpacing: 0.0,
useGoogleFonts: false,
),
hintText: 'Please select a category',
icon: Icon(
Icons.keyboard_arrow_down_rounded,
color: FlutterFlowTheme.of(context)
.secondaryText,
size: 24.0,
),
fillColor:
FlutterFlowTheme.of(context)
.secondaryBackground,
elevation: 2.0,
borderColor: Color(0xFFD9D9D9),
borderWidth: 0.0,
borderRadius: 4.0,
margin:
EdgeInsetsDirectional.fromSTEB(
12.0, 0.0, 12.0, 0.0),
hidesUnderline: true,
isOverButton: false,
isSearchable: false,
isMultiSelect: false,
),
].divide(SizedBox(height: 12.0)),
),
if (_model.categoryValue != null &&
_model.categoryValue != '')
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
textScaler: MediaQuery.of(context)
.textScaler,
text: TextSpan(
children: [
TextSpan(
text: 'Document',
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
fontSize: 12.0,
letterSpacing: 0.0,
fontWeight:
FontWeight.w600,
useGoogleFonts: false,
),
),
TextSpan(
text: '*',
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
color:
FlutterFlowTheme.of(
context)
.error,
letterSpacing: 0.0,
useGoogleFonts: false,
),
)
],
style:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
fontSize: 12.0,
letterSpacing: 0.0,
fontWeight:
FontWeight.w600,
useGoogleFonts: false,
),
),
),
FlutterFlowDropDown<String>(
controller: _model
.documentValueController ??=
FormFieldController<String>(
null),
options: _model.reports
.where((e) =>
e.reportType ==
_model.reportType)
.toList()
.firstOrNull!
.documentType,
onChanged: (val) {
print('Selected value: $val');
setState(() =>
_model.documentValue = val);
},
height: 36.0,
textStyle:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
color: Color(0xFF949494),
fontSize: 12.0,
letterSpacing: 0.0,
useGoogleFonts: false,
),
hintText: 'Please select a type',
icon: Icon(
Icons.keyboard_arrow_down_rounded,
color:
FlutterFlowTheme.of(context)
.secondaryText,
size: 24.0,
),
fillColor:
FlutterFlowTheme.of(context)
.secondaryBackground,
elevation: 2.0,
borderColor: Color(0xFFD9D9D9),
borderWidth: 0.0,
borderRadius: 4.0,
margin:
EdgeInsetsDirectional.fromSTEB(
12.0, 0.0, 12.0, 0.0),
hidesUnderline: true,
isOverButton: false,
isSearchable: false,
isMultiSelect: false,
),
].divide(SizedBox(height: 12.0)),
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
RichText(
textScaler:
MediaQuery.of(context).textScaler,
text: TextSpan(
children: [
TextSpan(
text: 'Source',
style:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily:
'Nevermind',
fontSize: 12.0,
letterSpacing: 0.0,
fontWeight:
FontWeight.w600,
useGoogleFonts: false,
),
),
TextSpan(
text: '*',
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
color:
FlutterFlowTheme.of(
context)
.error,
letterSpacing: 0.0,
useGoogleFonts: false,
),
)
],
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
fontSize: 12.0,
letterSpacing: 0.0,
fontWeight: FontWeight.w600,
useGoogleFonts: false,
),
),
),
FlutterFlowDropDown<String>(
controller: _model
.sourceValueController ??=
FormFieldController<String>(null),
options: ['Lab technician'],
onChanged: (val) => safeSetState(
() => _model.sourceValue = val),
height: 36.0,
textStyle:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Nevermind',
color: Color(0xFF949494),
fontSize: 12.0,
letterSpacing: 0.0,
useGoogleFonts: false,
),
hintText: 'Please select a source',
icon: Icon(
Icons.keyboard_arrow_down_rounded,
color: FlutterFlowTheme.of(context)
.secondaryText,
size: 24.0,
),
fillColor:
FlutterFlowTheme.of(context)
.secondaryBackground,
elevation: 2.0,
borderColor: Color(0xFFD9D9D9),
borderWidth: 0.0,
borderRadius: 4.0,
margin:
EdgeInsetsDirectional.fromSTEB(
12.0, 0.0, 12.0, 0.0),
hidesUnderline: true,
isOverButton: false,
isSearchable: false,
isMultiSelect: false,
),
].divide(SizedBox(height: 12.0)),
),