2022-09-04 19:54:21 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-10-12 02:00:39 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2023-10-28 16:19:07 +02:00
|
|
|
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
2024-02-12 00:22:25 +01:00
|
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
2023-10-12 02:00:39 +02:00
|
|
|
import 'package:revanced_manager/models/patch.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
2022-09-04 19:54:21 +02:00
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
class BooleanPatchOption extends StatelessWidget {
|
|
|
|
const BooleanPatchOption({
|
|
|
|
super.key,
|
|
|
|
required this.patchOption,
|
|
|
|
required this.removeOption,
|
|
|
|
required this.onChanged,
|
|
|
|
});
|
|
|
|
|
|
|
|
final Option patchOption;
|
|
|
|
final void Function(Option option) removeOption;
|
|
|
|
final void Function(dynamic value, Option option) onChanged;
|
2022-09-04 19:54:21 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-12 02:00:39 +02:00
|
|
|
final ValueNotifier patchOptionValue = ValueNotifier(patchOption.value);
|
|
|
|
return PatchOption(
|
|
|
|
widget: Align(
|
|
|
|
alignment: Alignment.bottomLeft,
|
|
|
|
child: ValueListenableBuilder(
|
|
|
|
valueListenable: patchOptionValue,
|
|
|
|
builder: (context, value, child) {
|
|
|
|
return Switch(
|
|
|
|
value: value ?? false,
|
|
|
|
onChanged: (bool value) {
|
|
|
|
patchOptionValue.value = value;
|
|
|
|
onChanged(value, patchOption);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2022-09-04 19:54:21 +02:00
|
|
|
),
|
|
|
|
),
|
2023-10-12 02:00:39 +02:00
|
|
|
patchOption: patchOption,
|
|
|
|
removeOption: (Option option) {
|
|
|
|
removeOption(option);
|
|
|
|
},
|
2022-09-04 19:54:21 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
class IntAndStringPatchOption extends StatelessWidget {
|
|
|
|
const IntAndStringPatchOption({
|
|
|
|
super.key,
|
|
|
|
required this.patchOption,
|
|
|
|
required this.removeOption,
|
|
|
|
required this.onChanged,
|
|
|
|
});
|
|
|
|
|
|
|
|
final Option patchOption;
|
|
|
|
final void Function(Option option) removeOption;
|
|
|
|
final void Function(dynamic value, Option option) onChanged;
|
2022-09-04 19:54:21 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-12 02:00:39 +02:00
|
|
|
final ValueNotifier patchOptionValue = ValueNotifier(patchOption.value);
|
2023-10-26 22:56:08 +02:00
|
|
|
String getKey() {
|
|
|
|
if (patchOption.value != null && patchOption.values != null) {
|
|
|
|
final List values = patchOption.values!.entries
|
|
|
|
.where((e) => e.value == patchOption.value)
|
|
|
|
.toList();
|
|
|
|
if (values.isNotEmpty) {
|
|
|
|
return values.first.key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
return PatchOption(
|
|
|
|
widget: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
TextFieldForPatchOption(
|
|
|
|
value: patchOption.value,
|
2023-10-26 22:56:08 +02:00
|
|
|
values: patchOption.values,
|
|
|
|
optionType: patchOption.valueType,
|
|
|
|
selectedKey: getKey(),
|
2023-10-12 02:00:39 +02:00
|
|
|
onChanged: (value) {
|
|
|
|
patchOptionValue.value = value;
|
|
|
|
onChanged(value, patchOption);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ValueListenableBuilder(
|
|
|
|
valueListenable: patchOptionValue,
|
|
|
|
builder: (context, value, child) {
|
|
|
|
if (patchOption.required && value == null) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2023-10-15 11:56:43 +02:00
|
|
|
children: [
|
2023-10-12 02:00:39 +02:00
|
|
|
const SizedBox(height: 8),
|
2024-02-12 00:22:25 +01:00
|
|
|
Text(
|
|
|
|
t.patchOptionsView.requiredOption,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const SizedBox();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
patchOption: patchOption,
|
|
|
|
removeOption: (Option option) {
|
|
|
|
removeOption(option);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class IntStringLongListPatchOption extends StatelessWidget {
|
|
|
|
const IntStringLongListPatchOption({
|
|
|
|
super.key,
|
|
|
|
required this.patchOption,
|
|
|
|
required this.removeOption,
|
|
|
|
required this.onChanged,
|
|
|
|
});
|
|
|
|
|
|
|
|
final Option patchOption;
|
|
|
|
final void Function(Option option) removeOption;
|
|
|
|
final void Function(dynamic value, Option option) onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-26 22:56:08 +02:00
|
|
|
final List<dynamic> values = List.from(patchOption.value ?? []);
|
2023-10-12 02:00:39 +02:00
|
|
|
final ValueNotifier patchOptionValue = ValueNotifier(values);
|
2023-10-26 22:56:08 +02:00
|
|
|
final String type = patchOption.valueType;
|
|
|
|
|
|
|
|
String getKey(dynamic value) {
|
|
|
|
if (value != null && patchOption.values != null) {
|
|
|
|
final List values = patchOption.values!.entries
|
|
|
|
.where((e) => e.value.toString() == value)
|
|
|
|
.toList();
|
|
|
|
if (values.isNotEmpty) {
|
|
|
|
return values.first.key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isCustomValue() {
|
|
|
|
if (values.length == 1 && patchOption.values != null) {
|
|
|
|
if (getKey(values[0]) != '') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isTextFieldVisible = isCustomValue();
|
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
return PatchOption(
|
2023-10-26 22:56:08 +02:00
|
|
|
widget: ValueListenableBuilder(
|
|
|
|
valueListenable: patchOptionValue,
|
|
|
|
builder: (context, value, child) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
ListView.builder(
|
2023-10-12 02:00:39 +02:00
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: value.length,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
final e = values[index];
|
|
|
|
return TextFieldForPatchOption(
|
|
|
|
value: e.toString(),
|
2023-10-26 22:56:08 +02:00
|
|
|
values: patchOption.values,
|
2023-10-12 02:00:39 +02:00
|
|
|
optionType: type,
|
2023-10-26 22:56:08 +02:00
|
|
|
selectedKey: value.length > 1 ? '' : getKey(e),
|
|
|
|
showDropdown: index == 0,
|
2023-10-12 02:00:39 +02:00
|
|
|
onChanged: (newValue) {
|
2023-10-26 22:56:08 +02:00
|
|
|
if (newValue is List) {
|
|
|
|
values.clear();
|
|
|
|
isTextFieldVisible = false;
|
|
|
|
values.add(newValue.toString());
|
|
|
|
} else {
|
|
|
|
isTextFieldVisible = true;
|
|
|
|
if (values.length == 1 &&
|
|
|
|
values[0].toString().startsWith('[') &&
|
|
|
|
type.contains('Array')) {
|
|
|
|
values.clear();
|
|
|
|
values.addAll(patchOption.value);
|
|
|
|
} else {
|
|
|
|
values[index] = type == 'StringArray'
|
|
|
|
? newValue
|
|
|
|
: type == 'IntArray'
|
|
|
|
? int.parse(
|
|
|
|
newValue.toString().isEmpty
|
|
|
|
? '0'
|
|
|
|
: newValue.toString(),
|
|
|
|
)
|
|
|
|
: num.parse(
|
|
|
|
newValue.toString().isEmpty
|
|
|
|
? '0'
|
|
|
|
: newValue.toString(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
patchOptionValue.value = List.from(values);
|
2023-10-12 02:00:39 +02:00
|
|
|
onChanged(values, patchOption);
|
|
|
|
},
|
2023-10-26 22:56:08 +02:00
|
|
|
removeValue: () {
|
2023-10-15 11:56:43 +02:00
|
|
|
patchOptionValue.value = List.from(patchOptionValue.value)
|
|
|
|
..removeAt(index);
|
2023-10-12 02:00:39 +02:00
|
|
|
values.removeAt(index);
|
|
|
|
onChanged(values, patchOption);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
if (isTextFieldVisible) ...[
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
if (type == 'StringArray') {
|
|
|
|
patchOptionValue.value =
|
|
|
|
List.from(patchOptionValue.value)..add('');
|
|
|
|
values.add('');
|
|
|
|
} else {
|
|
|
|
patchOptionValue.value =
|
|
|
|
List.from(patchOptionValue.value)..add(0);
|
|
|
|
values.add(0);
|
|
|
|
}
|
|
|
|
onChanged(values, patchOption);
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
const Icon(Icons.add, size: 20),
|
2024-02-12 00:22:25 +01:00
|
|
|
Text(
|
|
|
|
t.add,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w600,
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
2023-10-15 11:56:43 +02:00
|
|
|
),
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
|
|
|
patchOption: patchOption,
|
|
|
|
removeOption: (Option option) {
|
|
|
|
removeOption(option);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class UnsupportedPatchOption extends StatelessWidget {
|
|
|
|
const UnsupportedPatchOption({super.key, required this.patchOption});
|
2023-10-26 22:56:08 +02:00
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
final Option patchOption;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return PatchOption(
|
|
|
|
widget: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(
|
|
|
|
t.patchOptionsView.unsupportedOption,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
2022-09-04 19:54:21 +02:00
|
|
|
),
|
|
|
|
),
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
patchOption: patchOption,
|
|
|
|
removeOption: (_) {},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PatchOption extends StatelessWidget {
|
|
|
|
const PatchOption({
|
|
|
|
super.key,
|
|
|
|
required this.widget,
|
|
|
|
required this.patchOption,
|
|
|
|
required this.removeOption,
|
|
|
|
});
|
|
|
|
|
|
|
|
final Widget widget;
|
|
|
|
final Option patchOption;
|
|
|
|
final void Function(Option option) removeOption;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: CustomCard(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
patchOption.title,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
Text(
|
|
|
|
patchOption.description,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.onSecondaryContainer,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!patchOption.required)
|
|
|
|
IconButton(
|
|
|
|
onPressed: () => removeOption(patchOption),
|
|
|
|
icon: const Icon(Icons.delete),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
widget,
|
|
|
|
],
|
2022-09-06 19:07:23 +02:00
|
|
|
),
|
|
|
|
),
|
2023-10-12 02:00:39 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TextFieldForPatchOption extends StatefulWidget {
|
|
|
|
const TextFieldForPatchOption({
|
|
|
|
super.key,
|
|
|
|
required this.value,
|
2023-10-26 22:56:08 +02:00
|
|
|
required this.values,
|
2023-10-12 02:00:39 +02:00
|
|
|
this.removeValue,
|
|
|
|
required this.onChanged,
|
|
|
|
required this.optionType,
|
2023-10-26 22:56:08 +02:00
|
|
|
required this.selectedKey,
|
|
|
|
this.showDropdown = true,
|
2023-10-12 02:00:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
final String? value;
|
2023-10-26 22:56:08 +02:00
|
|
|
final Map<String, dynamic>? values;
|
2023-10-12 02:00:39 +02:00
|
|
|
final String optionType;
|
2023-10-26 22:56:08 +02:00
|
|
|
final String selectedKey;
|
|
|
|
final bool showDropdown;
|
|
|
|
final void Function()? removeValue;
|
2023-10-12 02:00:39 +02:00
|
|
|
final void Function(dynamic value) onChanged;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<TextFieldForPatchOption> createState() =>
|
|
|
|
_TextFieldForPatchOptionState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TextFieldForPatchOptionState extends State<TextFieldForPatchOption> {
|
|
|
|
final TextEditingController controller = TextEditingController();
|
2023-10-26 22:56:08 +02:00
|
|
|
String? selectedKey;
|
|
|
|
String? defaultValue;
|
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final bool isStringOption = widget.optionType.contains('String');
|
2023-10-26 22:56:08 +02:00
|
|
|
final bool isArrayOption = widget.optionType.contains('Array');
|
|
|
|
selectedKey ??= widget.selectedKey;
|
2023-12-23 04:47:12 +01:00
|
|
|
controller.text = !isStringOption &&
|
|
|
|
isArrayOption &&
|
|
|
|
selectedKey == '' &&
|
2023-10-26 22:56:08 +02:00
|
|
|
(widget.value != null && widget.value.toString().startsWith('['))
|
|
|
|
? ''
|
|
|
|
: widget.value ?? '';
|
|
|
|
defaultValue ??= controller.text;
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
if (widget.showDropdown && (widget.values?.isNotEmpty ?? false))
|
|
|
|
DropdownButton<String>(
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(4),
|
|
|
|
dropdownColor: Theme.of(context).colorScheme.secondaryContainer,
|
|
|
|
isExpanded: true,
|
|
|
|
value: selectedKey,
|
|
|
|
items: widget.values!.entries
|
|
|
|
.map(
|
|
|
|
(e) => DropdownMenuItem(
|
|
|
|
value: e.key,
|
|
|
|
child: RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
text: e.key,
|
2024-01-21 14:36:23 +01:00
|
|
|
style: TextStyle(
|
2023-10-26 22:56:08 +02:00
|
|
|
fontSize: 16,
|
2024-01-21 14:36:23 +01:00
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.onSecondaryContainer,
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: ' ${e.value}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.onSecondaryContainer
|
|
|
|
.withOpacity(0.6),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList()
|
|
|
|
..add(
|
|
|
|
DropdownMenuItem(
|
|
|
|
value: '',
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(
|
|
|
|
t.patchOptionsView.customValue,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
),
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
onChanged: (value) {
|
|
|
|
if (value == '') {
|
|
|
|
controller.text = defaultValue!;
|
|
|
|
widget.onChanged(controller.text);
|
|
|
|
} else {
|
|
|
|
controller.text = widget.values![value].toString();
|
|
|
|
widget.onChanged(
|
|
|
|
isArrayOption ? widget.values![value] : controller.text,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
selectedKey = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
if (selectedKey == '')
|
|
|
|
TextFormField(
|
|
|
|
inputFormatters: [
|
|
|
|
if (widget.optionType.contains('Int'))
|
|
|
|
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
|
|
if (widget.optionType.contains('Long'))
|
|
|
|
FilteringTextInputFormatter.allow(RegExp(r'^[0-9]*\.?[0-9]*')),
|
|
|
|
],
|
|
|
|
controller: controller,
|
|
|
|
keyboardType:
|
|
|
|
isStringOption ? TextInputType.text : TextInputType.number,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
suffixIcon: PopupMenuButton(
|
2024-02-12 00:22:25 +01:00
|
|
|
tooltip: t.patchOptionsView.tooltip,
|
2023-10-26 22:56:08 +02:00
|
|
|
itemBuilder: (BuildContext context) {
|
|
|
|
return [
|
|
|
|
if (isArrayOption)
|
|
|
|
PopupMenuItem(
|
2024-02-12 00:22:25 +01:00
|
|
|
value: t.remove,
|
|
|
|
child: Text(t.remove),
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
if (isStringOption) ...[
|
|
|
|
PopupMenuItem(
|
2024-02-12 00:22:25 +01:00
|
|
|
value: t.patchOptionsView.selectFilePath,
|
|
|
|
child: Text(t.patchOptionsView.selectFilePath),
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
PopupMenuItem(
|
2024-02-12 00:22:25 +01:00
|
|
|
value: t.patchOptionsView.selectFolder,
|
|
|
|
child: Text(t.patchOptionsView.selectFolder),
|
2023-10-26 22:56:08 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
];
|
|
|
|
},
|
|
|
|
onSelected: (String selection) async {
|
|
|
|
switch (selection) {
|
|
|
|
case 'patchOptionsView.selectFilePath':
|
2023-10-28 16:19:07 +02:00
|
|
|
final String? result = await FlutterFileDialog.pickFile();
|
|
|
|
if (result != null) {
|
|
|
|
controller.text = result;
|
2023-10-26 22:56:08 +02:00
|
|
|
widget.onChanged(controller.text);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'patchOptionsView.selectFolder':
|
2023-12-23 04:47:12 +01:00
|
|
|
final DirectoryLocation? result =
|
|
|
|
await FlutterFileDialog.pickDirectory();
|
2023-10-26 22:56:08 +02:00
|
|
|
if (result != null) {
|
2023-10-28 16:19:07 +02:00
|
|
|
controller.text = result.toString();
|
2023-10-26 22:56:08 +02:00
|
|
|
widget.onChanged(controller.text);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'remove':
|
|
|
|
widget.removeValue!();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onChanged: (String value) {
|
|
|
|
widget.onChanged(value);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
2022-09-04 19:54:21 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|