Open sgarg15 opened 3 years ago
I am still having this issue. If someone could help me out, I will really appreciate it. Thank you!
Hi, I'm having the exact same issue as well. Thanks for this plugin but I really hope this can be resolved. Thank you
I also can't seem to get InitValue to work at all? Below is super simplified code that hard-codes an initial value. However, it doesn't appear/work.
Can you confirm if initialValue is working at all?
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/multi_select_flutter.dart';
import '../../api/api_manager.dart';
import '../../models/option.dart';
class GBSelectFilter extends StatefulWidget {
final Map filter;
final Map column;
final int tableId;
final Function removeFilter;
final Function updateFilter;
const GBSelectFilter(
{Key? key,
required this.filter,
required this.removeFilter,
required this.updateFilter,
required this.column,
required this.tableId})
: super(key: key);
@override
_GBSelectFilterState createState() => _GBSelectFilterState();
}
class _GBSelectFilterState extends State<GBSelectFilter> {
List<MultiSelectItem<Object?>> _items=[] ;
List<Option> _selectedOptions = [Option(optionId: 1,option: 'Red',attributes: {'color':'red'})];
@override
void initState() {
getListData();
super.initState();
}
Future<void> getListData() async {
List<Option> data = await ApiManager.getListData(widget.tableId, widget.column);
print(data[0].optionId);
this.setState(() {
_items=data
.map((opt) => MultiSelectItem<Option>(opt, opt.option))
.toList();
});
}
@override
Widget build(BuildContext context) {
return Container(
child: MultiSelectDialogField(
items: _items,
initialValue: _selectedOptions,
title: Text("Colors"),
selectedColor: Colors.blue,
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
borderRadius: BorderRadius.all(Radius.circular(40)),
border: Border.all(
color: Colors.blue,
width: 2,
),
),
buttonIcon: Icon(
Icons.pets,
color: Colors.blue,
),
buttonText: Text(
"Favorite Animals",
style: TextStyle(
color: Colors.blue[800],
fontSize: 16,
),
),
onConfirm: (results) {
// _selectedOptions=results as List<Option>;
},
),
// Column(children: _options.map((e) {
// return Text(e.option);
// }).toList(),),
);
}
}
Having this same issue, Code which was working in previous versions is now not working for initalValue, No changes to the code, InitialValue no longer shows any values, Please can you look into this?
Having this same issue, Code which was working in previous versions is now not working for initalValue, No changes to the code, InitialValue no longer shows any values, Please can you look into this?
I have solve this issue, this issue help me,hope it can help you。#11
Having this same issue, Code which was working in previous versions is now not working for initalValue, No changes to the code, InitialValue no longer shows any values, Please can you look into this?
I have solve this issue, this issue help me,hope it can help you。#11
This worked in helping me find the solution, I am using Equatable in model definition, so needed to build both All Items and the selected Items arrays with the exact same values for the model, this fixed the issue with the initialValues showing properly, Thank you @qs991011 for pointing to this solution
Sigh.. still not working ;-( and kinda a showstopper.. so off to find another
not usable, the initial set does not work, I immediately change the plugin
Yea, I have this issue, and given the age of the bug, I'm going to pass on this plugin. Sorry, otherwise it's really useful, but this is an absolute requirement for any form field (to be able to pre-populate), and I'd prioritize fixing this one.
hey everyone, so I am using
MultiSelectBottomSheetField
And I am having some issues with the initialValue parameter for it. So at the moment, I have data saved in firestore as a string but its in the format of a list. And what i was trying to do was get the string data from firestore -> convert to a list with the respective class -> and then show as initial value in the above package/widget. But whats happening is that the initial value isnt showing, even though the value is not empty. So for context this is how I change to list from firestore string:this is how i use the acc widget:
And this is my initState:
If someone could help me out, it would be very appreciated.
Thanks!!