73 lines
2.4 KiB
Dart
73 lines
2.4 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:multi_select_flutter/chip_display/multi_select_chip_display.dart';
|
|
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
|
|
import 'package:multi_select_flutter/util/multi_select_item.dart';
|
|
import 'package:multi_select_flutter/util/multi_select_list_type.dart';
|
|
|
|
class MultiSelectDropdownContainer extends StatelessWidget {
|
|
final Color color;
|
|
final String label;
|
|
final List<String> values;
|
|
final List<String> initialValue;
|
|
final bool isMultiple;
|
|
final bool isAtLeastOne;
|
|
final double fontSize;
|
|
final ValueChanged<List<dynamic>> onChanged;
|
|
const MultiSelectDropdownContainer({
|
|
Key key,
|
|
this.color = kSecond,
|
|
this.label,
|
|
this.values,
|
|
this.initialValue,
|
|
this.isMultiple,
|
|
this.isAtLeastOne = false,
|
|
this.fontSize = 25,
|
|
this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Size size = MediaQuery.of(context).size;
|
|
return Container(
|
|
child: Row(
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: AutoSizeText(
|
|
label,
|
|
style: TextStyle(fontSize: fontSize, fontWeight: FontWeight.w300),
|
|
maxLines: 2,
|
|
maxFontSize: fontSize,
|
|
textAlign: TextAlign.center,
|
|
)
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Container(
|
|
width: size.width *0.2,
|
|
child: MultiSelectDialogField(
|
|
items: values.map((e) => MultiSelectItem(e, e)).toList(),
|
|
listType: MultiSelectListType.LIST,
|
|
cancelText: Text("Annuler"),
|
|
initialValue: initialValue,
|
|
buttonText: Text("Sélectionner"),
|
|
checkColor: Colors.white,
|
|
searchable: true,
|
|
chipDisplay: MultiSelectChipDisplay.none(),
|
|
selectedColor: kPrimaryColor,
|
|
title: Text("Veuillez sélectionner une langue"),
|
|
dialogHeight: size.height *0.4,
|
|
dialogWidth: size.width *0.2,
|
|
onSelectionChanged: (selectedList) {
|
|
onChanged(selectedList);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |