• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / flutter / 30854254088

03 Aug 2026 09:21PM UTC coverage: 40.895% (-15.0%) from 55.93%
30854254088

Pull #1260

github

web-flow
Merge d93794de5 into e3affdd4f
Pull Request #1260: WIP: health sync

9980 of 24404 relevant lines covered (40.89%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.0
/lib/features/exercises/widgets/forms.dart
1
/*
2
 * This file is part of wger Workout Manager <https://github.com/wger-project>.
3
 * Copyright (c)  2026 wger Team
4
 *
5
 * wger Workout Manager is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

19
import 'package:flutter/material.dart';
20

21
/// Input widget for exercise category objects
22
///
23
/// Can be used with a Setting or a Log object
24
class ExerciseCategoryInputWidget<T> extends StatefulWidget {
25
  late final String _title;
26
  late final Function _callback;
27
  late final List<T> _entries;
28
  late final Function _getDisplayName;
29
  late final Function? _validator;
30

31
  ExerciseCategoryInputWidget({
1✔
32
    super.key,
33
    required String title,
34
    required List<T> entries,
35
    required Function callback,
36
    required Function displayName,
37
    Function? validator,
38
  }) {
39
    _entries = entries;
1✔
40
    _title = title;
1✔
41
    _callback = callback;
1✔
42
    _getDisplayName = displayName;
1✔
43
    _validator = validator;
1✔
44
  }
45

46
  @override
1✔
47
  _ExerciseCategoryInputWidgetState createState() => _ExerciseCategoryInputWidgetState<T>();
1✔
48
}
49

50
class _ExerciseCategoryInputWidgetState<T> extends State<ExerciseCategoryInputWidget> {
51
  @override
1✔
52
  Widget build(BuildContext context) {
53
    T? selectedEntry;
54

55
    return Padding(
1✔
56
      padding: const EdgeInsets.all(8.0),
57
      child: DropdownButtonFormField(
1✔
58
        key: widget.key,
2✔
59
        initialValue: selectedEntry,
60
        decoration: InputDecoration(
1✔
61
          labelText: widget._title,
2✔
62
          contentPadding: const EdgeInsets.all(8.0),
63
          border: const OutlineInputBorder(
64
            borderRadius: BorderRadius.all(Radius.circular(10)),
65
          ),
66
        ),
67
        onChanged: (T? newValue) {
×
68
          setState(() {
×
69
            selectedEntry = newValue as T;
70
            widget._callback(newValue);
×
71
          });
72
        },
73
        validator: (T? value) {
×
74
          if (widget._validator != null) {
×
75
            return widget._validator!(value);
×
76
          }
77
          return null;
78
        },
79
        items: widget._entries.map<DropdownMenuItem<T>>((value) {
3✔
80
          return DropdownMenuItem<T>(
×
81
            key: ValueKey(value),
×
82
            value: value,
83
            child: Text(widget._getDisplayName(value)),
×
84
          );
85
        }).toList(),
1✔
86
      ),
87
    );
88
  }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc