Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: avoid_unnecessary_containers linter rule #204

Open
wants to merge 2 commits into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions lib/UI/exercise/add_exercise_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,19 @@ class _ExerciseNameSelectionWidgetState extends State<ExerciseNameSelectionWidge
subtitle1: setStyle,
),
),
child: Container(
child: Autocomplete<String>(
optionsMaxHeight: 100,
onSelected: (String value) {
widget.setExercisename(value);
},
optionsBuilder: (TextEditingValue textEditingValue) {
widget.setExercisename(textEditingValue.text);
return snapshot.data!.where(
(String name) => name.toLowerCase().startsWith(
textEditingValue.text.toLowerCase(),
),
);
},
),
child: Autocomplete<String>(
optionsMaxHeight: 100,
onSelected: (String value) {
widget.setExercisename(value);
},
optionsBuilder: (TextEditingValue textEditingValue) {
widget.setExercisename(textEditingValue.text);
return snapshot.data!.where(
(String name) => name.toLowerCase().startsWith(
textEditingValue.text.toLowerCase(),
),
);
},
),
),
);
Expand Down
44 changes: 20 additions & 24 deletions lib/UI/exercise/exercise_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,28 @@ class _ExerciseCardState extends State<ExerciseCard> with AutomaticKeepAliveClie
height: height,
child: Column(
children: <Widget> [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget> [
Container(
height: getHeight(),
width: screenWidth * 0.45,
child: Text(
widget.name,
style: mediumTitleStyleWhite,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget> [
Container(
height: getHeight(),
width: screenWidth * 0.45,
child: Text(
widget.name,
style: mediumTitleStyleWhite,
),
Container(
child: ValueListenableBuilder<TotalsData>(
valueListenable: _notifier,
builder: (BuildContext context, TotalsData value,
),
ValueListenableBuilder<TotalsData>(
valueListenable: _notifier,
builder: (BuildContext context, TotalsData value,
Widget? child) {
return ExerciseTotalsWidget(
totals: value,
index: index,
);
},
),
),
],
),
return ExerciseTotalsWidget(
totals: value,
index: index,
);
},
),
],
),
Divider(
thickness: 1,
Expand Down
26 changes: 12 additions & 14 deletions lib/UI/prev_workout/prev_exercise_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,19 @@ class _PrevExerciseCardState extends State<PrevExerciseCard> with AutomaticKeepA
height: height,
child: Column(
children: <Widget> [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: getHeight(),
width: screenWidth * 0.45,
child: Text(
widget.name,
style: mediumTitleStyleWhite,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: getHeight(),
width: screenWidth * 0.45,
child: Text(
widget.name,
style: mediumTitleStyleWhite,
),
totalWidget
],
),
),
totalWidget
],
),
Divider(
thickness: 1,
Expand Down
9 changes: 3 additions & 6 deletions lib/UI/prev_workout/prev_workout_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ class _PrevWorkoutPageState extends State<PrevWorkoutPage> {
totals: workoutData.totals,
),
Expanded(
child: Container(
//height: screenHeight * 0.5,
child: ListView(
addAutomaticKeepAlives: true,
children: workoutData.exerciseWidgets,
),
child: ListView(
addAutomaticKeepAlives: true,
children: workoutData.exerciseWidgets,
),
),
],
Expand Down
42 changes: 19 additions & 23 deletions lib/UI/workout/save_workout_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,25 @@ class _SaveWorkoutAlertState extends State<SaveWorkoutAlert> {
),
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget> [
Container(
child: Text(
'Save as template',
style: mediumTitleStyleWhite,
),
),
Checkbox(
fillColor: MaterialStateProperty.all<Color>(theme.colorTheme.primaryColor),
value: this.template,
onChanged: (bool? value) {
setState(() {
Log.info(value.toString());
template = value;
widget.setWorkout(name, template!);
});
},
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget> [
Text(
'Save as template',
style: mediumTitleStyleWhite,
),
Checkbox(
fillColor: MaterialStateProperty.all<Color>(theme.colorTheme.primaryColor),
value: this.template,
onChanged: (bool? value) {
setState(() {
Log.info(value.toString());
template = value;
widget.setWorkout(name, template!);
});
},
),
],
),
Container(
height: screenHeight * 0.05,
Expand Down
88 changes: 33 additions & 55 deletions lib/UI/workout/workout_toatals_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ class _WorkoutTotalsWidgetState extends State<WorkoutTotalsWidget> {
children: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(
'Totals',
style: mediumTitleStyleWhite,
),
Text(
'Totals',
style: mediumTitleStyleWhite,
)
],
),
Expand All @@ -49,81 +47,61 @@ class _WorkoutTotalsWidgetState extends State<WorkoutTotalsWidget> {
children: <Widget> [
Column(
children: <Widget> [
Container(
child: Text(
'sets',
style: setStyle,
),
Text(
'sets',
style: setStyle,
),
Container(
child: Text(
widget.totals.sets.toString(),
style: setStyle,
),
Text(
widget.totals.sets.toString(),
style: setStyle,
)
],
),
Column(
children: <Widget>[
Container(
child: Text(
'reps',
style: setStyle,
),
Text(
'reps',
style: setStyle,
),
Container(
child: Text(
widget.totals.reps.toString(),
style: setStyle,
),
Text(
widget.totals.reps.toString(),
style: setStyle,
)
],
),
Column(
children: <Widget> [
Container(
child: Text(
'load',
style: setStyle,
),
Text(
'load',
style: setStyle,
),
Container(
child: Text(
widget.totals.weight.toString(),
style: setStyle,
),
Text(
widget.totals.weight.toString(),
style: setStyle,
)
],
),
Column(
children: <Widget> [
Container(
child: Text(
'kg/rep',
style: setStyle,
),
Text(
'kg/rep',
style: setStyle,
),
Container(
child: Text(
widget.totals.avgKgs.toString(),
style: setStyle,
),
Text(
widget.totals.avgKgs.toString(),
style: setStyle,
)
],
),
Column(
children: <Widget> [
Container(
child: Text(
'exercises',
style: setStyle,
),
Text(
'exercises',
style: setStyle,
),
Container(
child: Text(
widget.totals.exercises.toString(),
style: setStyle,
),
Text(
widget.totals.exercises.toString(),
style: setStyle,
)
],
),
Expand Down
4 changes: 1 addition & 3 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ void main() {
await tester.runAsync(() async {
await tester.pumpWidget(MaterialApp(
title: 'EXERLOG',
home: Container(
child: const Text('EXERLOG'),
),
home: const Text('EXERLOG'),
),);
});
}
Expand Down