Add initial selection to instrument selector

Also use this from the work editor.
This commit is contained in:
Elias Projahn 2019-12-11 13:19:56 +01:00
parent 4855cafdf3
commit 40acc2b555
2 changed files with 19 additions and 2 deletions

View file

@ -5,6 +5,12 @@ import '../database.dart';
import '../editors/instrument.dart';
class InstrumentsSelector extends StatefulWidget {
final List<Instrument> selection;
InstrumentsSelector({
this.selection,
});
@override
_InstrumentsSelectorState createState() => _InstrumentsSelectorState();
}
@ -12,6 +18,15 @@ class InstrumentsSelector extends StatefulWidget {
class _InstrumentsSelectorState extends State<InstrumentsSelector> {
Set<Instrument> selection = {};
@override
void initState() {
super.initState();
if (widget.selection != null) {
selection = widget.selection.toSet();
}
}
@override
Widget build(BuildContext context) {
final backend = Backend.of(context);
@ -65,7 +80,7 @@ class _InstrumentsSelectorState extends State<InstrumentsSelector> {
builder: (context) => InstrumentEditor(),
fullscreenDialog: true,
));
if (instrument != null) {
setState(() {
selection.add(instrument);