-
Notifications
You must be signed in to change notification settings - Fork 44
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
Reviewed code #93
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ class _ButtonBuilderExampleState extends State<ButtonBuilderExample> { | |
late GroupButtonController _checkboxesController; | ||
late GroupButtonController _radioController; | ||
|
||
final _checkboxButtons = [ | ||
final List<String> _checkboxButtons = [ | ||
'Michael Jordan', | ||
'Magic Johnson', | ||
'LeBron James', | ||
|
@@ -22,7 +22,7 @@ class _ButtonBuilderExampleState extends State<ButtonBuilderExample> { | |
'Larry Bird', | ||
]; | ||
|
||
final _radioButtons = [ | ||
final List<String> _radioButtons = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
|
||
return Scaffold( | ||
drawer: const AppDrawer(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
|
||
int get buttonsCount => _buttonsCount; | ||
set buttonsCount(int count) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]!, | ||
|
@@ -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( | ||
|
@@ -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]!, | ||
|
@@ -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'), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
], | ||
|
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
|
||
int get selectedGroupingType => _selectedGroupingType; | ||
set selectedGroupingType(int value) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
if (userAnswers[i]) { | ||
indexes.add(i); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless type specification |
||
|
||
Exercise get exercise => _exercise; | ||
set exercise(Exercise val) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless type specification