This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/widgets/project_selector.dart
bvandeusen def7519feb fix: resolve all flutter analyze warnings and infos
- app.dart: add braces to single-statement if body
- briefing_api.dart: escape <id> in doc comment (unintended HTML)
- notes_api.dart, tasks_api.dart, projects_api.dart: use null-aware
  map elements (?'key': value) instead of if-null guards
- task_edit_screen.dart: remove unused tasks_api.dart import
- task_edit_screen.dart, project_selector.dart: suppress
  deprecated_member_use on DropdownButtonFormField.value (value is
  the controlled-widget param; switching to initialValue would break
  current-selection display)
- project_selector.dart: use _ instead of __ for ignored error params
2026-03-12 00:36:05 -04:00

57 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../providers/projects_provider.dart';
/// Dropdown for picking a project. Pass [value] as the current project id
/// (null = no project) and [onChanged] to receive updates.
class ProjectSelector extends ConsumerWidget {
final int? value;
final ValueChanged<int?> onChanged;
final InputDecoration? decoration;
const ProjectSelector({
super.key,
required this.value,
required this.onChanged,
this.decoration,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final projectsAsync = ref.watch(projectsProvider);
return projectsAsync.when(
loading: () => const LinearProgressIndicator(),
error: (_, _) => const SizedBox.shrink(),
data: (projects) {
final active =
projects.where((p) => p.status == 'active').toList();
return DropdownButtonFormField<int?>(
// ignore: deprecated_member_use
value: value,
decoration: decoration ??
const InputDecoration(
labelText: 'Project (optional)',
border: OutlineInputBorder(),
),
items: [
const DropdownMenuItem<int?>(
value: null,
child: Text('No project'),
),
...active.map(
(p) => DropdownMenuItem<int?>(
value: p.id,
child: Text(p.title, overflow: TextOverflow.ellipsis),
),
),
],
onChanged: onChanged,
);
},
);
}
}