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

Reviewed code #93

Merged
merged 5 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion example/lib/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import 'main.dart';
import 'routes.dart';

class AppDrawer extends StatelessWidget {
const AppDrawer({Key? key}) : super(key: key);
Expand Down
13 changes: 10 additions & 3 deletions example/lib/examples/button_builder_example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class _ButtonBuilderExampleState extends State<ButtonBuilderExample> {
late GroupButtonController _checkboxesController;
late GroupButtonController _radioController;

final _checkboxButtons = [
final List<String> _checkboxButtons = [
'Michael Jordan',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification

'Magic Johnson',
'LeBron James',
Expand All @@ -22,7 +22,7 @@ class _ButtonBuilderExampleState extends State<ButtonBuilderExample> {
'Larry Bird',
];

final _radioButtons = [
final List<String> _radioButtons = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add types where it is not necessary ?

'Cola',
'Potato chips',
'Pudding',
Expand All @@ -48,9 +48,16 @@ class _ButtonBuilderExampleState extends State<ButtonBuilderExample> {
super.initState();
}

@override
void dispose() {
_checkboxesController.dispose();
_radioController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final ThemeData theme = Theme.of(context);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


return Scaffold(
drawer: const AppDrawer(),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/examples/common_example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:group_button/group_button.dart';
class CommonExample extends StatelessWidget {
CommonExample({Key? key}) : super(key: key);

final controller = GroupButtonController(
final GroupButtonController controller = GroupButtonController(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification

selectedIndex: 20,
selectedIndexes: [0, 1, 2, 3, 4],
disabledIndexes: [10, 12, 13, 14, 15, 23],
Expand Down
41 changes: 21 additions & 20 deletions example/lib/examples/customizable_example/customizable_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ import 'package:group_button/group_button.dart';

class CustomizableExample extends StatelessWidget {
CustomizableExample({Key? key}) : super(key: key);
final controller = GroupButtonController(
final GroupButtonController controller = GroupButtonController(
onDisablePressed: (i) => debugPrint('Disable Button #$i pressed'),
);
final customizableController = CustomizableExampleController();
final CustomizableExampleController customizableController =
CustomizableExampleController();
Comment on lines +10 to +14
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: customizableController,
builder: (context, child) {
return Scaffold(
drawer: const AppDrawer(),
appBar: AppBar(
title: Text(
'GroupButton 5.0.0',
),
),
body: Center(
return Scaffold(
drawer: const AppDrawer(),
appBar: AppBar(
title: Text(
'GroupButton 5.0.0',
),
),
body: AnimatedBuilder(
animation: customizableController,
builder: (context, child) {
return Center(
child: GroupButton(
controller: controller,
isRadio: false,
Expand All @@ -34,13 +35,13 @@ class CustomizableExample extends StatelessWidget {
onSelected: (val, i, selected) =>
debugPrint('Button: $val index: $i $selected'),
),
),
bottomNavigationBar: GroupButtonBottomPanel(
controller: controller,
customizableController: customizableController,
),
);
},
);
},
),
bottomNavigationBar: GroupButtonBottomPanel(
controller: controller,
customizableController: customizableController,
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

class CustomizableExampleController extends ChangeNotifier {
var _buttonsCount = 25;
int _buttonsCount = 25;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


int get buttonsCount => _buttonsCount;
set buttonsCount(int count) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ class GroupButtonBottomPanel extends StatelessWidget {

@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final Size size = MediaQuery.of(context).size;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification

return SizedBox(
height: 300,
child: Column(
children: [
Container(
height: 100,
width: MediaQuery.of(context).size.width,
width: size.width,
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
color: theme.cardColor,
boxShadow: [
BoxShadow(
color: Colors.grey[100]!,
Expand All @@ -39,7 +41,7 @@ class GroupButtonBottomPanel extends StatelessWidget {
padding: const EdgeInsets.only(left: 30.0),
child: Text(
'Buttons count ${customizableController.buttonsCount}',
style: Theme.of(context).textTheme.headline6,
style: theme.textTheme.headline6,
),
),
Slider(
Expand All @@ -56,9 +58,9 @@ class GroupButtonBottomPanel extends StatelessWidget {
),
Container(
height: 200,
width: MediaQuery.of(context).size.width,
width: size.width,
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
color: theme.cardColor,
boxShadow: [
BoxShadow(
color: Colors.grey[100]!,
Expand All @@ -67,57 +69,55 @@ class GroupButtonBottomPanel extends StatelessWidget {
)
],
),
child: Padding(
padding: const EdgeInsets.only(left: 30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Managed by controller',
style: Theme.of(context).textTheme.headline6,
),
Wrap(
spacing: 10,
children: [
ElevatedButton(
onPressed: () => controller.selectIndex(0),
child: const Text('Select #1'),
),
ElevatedButton(
onPressed: () => controller.unselectIndex(0),
child: const Text('Unelect #1'),
),
ElevatedButton(
onPressed: () =>
controller.selectIndexes([0, 1, 2, 3, 4]),
child: const Text('Select line'),
),
ElevatedButton(
onPressed: () =>
controller.unselectIndexes([0, 1, 2, 3, 4]),
child: const Text('Uelect line'),
),
ElevatedButton(
onPressed: () =>
controller.toggleIndexes([0, 1, 2, 3, 4]),
child: const Text('Toggle line'),
),
ElevatedButton(
onPressed: () => controller
..unselectAll()
..selectIndexes([2, 7, 12, 17, 22])
..selectIndexes([10, 11, 12, 13, 14]),
child: const Text('Make +'),
),
ElevatedButton(
onPressed: () => controller.unselectAll(),
child: const Text('Unselect all'),
),
],
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Managed by controller',
style: theme.textTheme.headline6,
),
Wrap(
spacing: 10,
alignment: WrapAlignment.center,
children: [
ElevatedButton(
onPressed: () => controller.selectIndex(0),
child: const Text('Select #1'),
),
ElevatedButton(
onPressed: () => controller.unselectIndex(0),
child: const Text('Unselect #1'),
),
ElevatedButton(
onPressed: () =>
controller.selectIndexes([0, 1, 2, 3, 4]),
child: const Text('Select line'),
),
ElevatedButton(
onPressed: () =>
controller.unselectIndexes([0, 1, 2, 3, 4]),
child: const Text('Unselect line'),
),
ElevatedButton(
onPressed: () =>
controller.toggleIndexes([0, 1, 2, 3, 4]),
child: const Text('Toggle line'),
),
ElevatedButton(
onPressed: () => controller
..unselectAll()
..selectIndexes([2, 7, 12, 17, 22])
..selectIndexes([10, 11, 12, 13, 14]),
child: const Text('Make +'),
),
ElevatedButton(
onPressed: () => controller.unselectAll(),
child: const Text('Unselect all'),
),
],
),
],
),
),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of 'example.dart';

Widget _buildCheckboxExample(GroupingType groupingType, {Axis? direction}) {
return ScrollIjector(
return ScrollInjector(
groupingType: groupingType,
child: Padding(
padding: const EdgeInsets.all(10.0),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/examples/extended_example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ part 'radio_example_part.dart';
part 'checkbox_example_part.dart';

class GroupButtonExtendedExample extends StatelessWidget {
GroupButtonExtendedExample({Key? key}) : super(key: key);
const GroupButtonExtendedExample({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:group_button/group_button.dart';

class ScrollIjector extends StatelessWidget {
const ScrollIjector({
class ScrollInjector extends StatelessWidget {
const ScrollInjector({
Key? key,
required this.child,
required this.groupingType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of 'example.dart';

Widget _buildRadioExample(GroupingType groupingType, {Axis? direction}) {
return ScrollIjector(
return ScrollInjector(
groupingType: groupingType,
child: Padding(
padding: const EdgeInsets.all(10.0),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';

class ExtendedExampleController extends ChangeNotifier {
var _selectedGroupingType = 0;
int _selectedGroupingType = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


int get selectedGroupingType => _selectedGroupingType;
set selectedGroupingType(int value) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/examples/generics_example/generics_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import 'package:group_button/group_button.dart';
class GenericsExample extends StatelessWidget {
GenericsExample({Key? key}) : super(key: key);

final controller = GroupButtonController(
final GroupButtonController controller = GroupButtonController(
selectedIndex: 0,
onDisablePressed: (i) => print('Button #$i is disabled'),
);

final day = DateTime(2022, 4, 9);
final DateTime day = DateTime(2022, 4, 9);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/examples/provider_example/models/exercise.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Exercise {
final List<Question> questions;

void updateAnswer(int questionIndex, int index, {required bool value}) =>
questions[questionIndex].updateAnsver(index, value: value);
questions[questionIndex].updateAnswer(index, value: value);

@override
String toString() => 'Exercise(questions: $questions)';
Expand Down
4 changes: 2 additions & 2 deletions example/lib/examples/provider_example/models/question.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class Question {
List<bool> answers;
List<bool> userAnswers;

void updateAnsver(int index, {required bool value}) {
void updateAnswer(int index, {required bool value}) {
userAnswers[index] = value;
}

List<int> get selectedIndexes {
final indexes = <int>[];
for (var i = 0; i < userAnswers.length; i++) {
for (int i = 0; i < userAnswers.length; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification

if (userAnswers[i]) {
indexes.add(i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import 'package:example/examples/provider_example/models/models.dart';
import 'package:example/examples/provider_example/models/question.dart';
import 'package:flutter/material.dart';

class ExarcisesProvider extends ChangeNotifier {
var _exercise = Exercise(
class ExercisesProvider extends ChangeNotifier {
Exercise _exercise = Exercise(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification

questions: [
Question(
'Wich numbers less then 3?',
'Which numbers less then 3?',
[true, true, false, false],
[false, false, false, false],
['0', '1', '8', '9'],
),
Question(
'Wich numbers more then 3?',
'Which numbers more then 3?',
[false, false, true, true],
[false, false, false, false],
['1', '-10', '11', '9'],
),
],
);
var _selectedIndex = 0;
int _selectedIndex = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless type specification


Exercise get exercise => _exercise;
set exercise(Exercise val) {
Expand Down
Loading