Skip to content

Commit fe1fe33

Browse files
Sandip KakadiyaSandip Kakadiya
authored andcommitted
code analyzed
1 parent dd8751f commit fe1fe33

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ analyzer:
44
- getflutter_app
55
- getflutter-app-kit
66
- getflutter-web-kit
7+
- test/.test_coverage.dart
78

89
linter:
910
rules:

example/lib/main.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class _MyHomePageState extends State<MyHomePage>
6767
'Xamarin2',
6868
];
6969

70-
var rating = 3.5;
70+
double rating = 3.5;
7171

7272
@override
7373
Widget build(BuildContext context) => Scaffold(
@@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage>
7979
gradient: LinearGradient(
8080
begin: Alignment.topRight,
8181
end: Alignment.bottomLeft,
82-
stops: [0.1, 0.5, 0.7, 0.9],
82+
stops: const [0.1, 0.5, 0.7, 0.9],
8383
colors: [
8484
Colors.teal[800],
8585
Colors.teal[600],
@@ -234,21 +234,21 @@ class _MyHomePageState extends State<MyHomePage>
234234
GFCard(
235235
content: Column(
236236
children: <Widget>[
237-
GFTypography(
237+
const GFTypography(
238238
text: 'Toast',
239239
type: GFTypographyType.typo6,
240240
),
241-
SizedBox(
241+
const SizedBox(
242242
height: 20,
243243
),
244-
SizedBox(
244+
const SizedBox(
245245
height: 20,
246246
),
247247
GFToast(
248248
text: 'Happy New Year',
249249
button: GFButton(
250250
onPressed: () {
251-
print("dfr");
251+
print('dfr');
252252
},
253253
text: 'OK',
254254
type: GFButtonType.outline,

lib/components/rating/gf_rating.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import 'package:flutter/material.dart';
22

3-
typedef void RatingChangeCallback(double rating);
3+
typedef RatingChangeCallback = void Function(double rating);
44

55
class GFRating extends StatelessWidget {
6-
GFRating({
6+
const GFRating({
77
this.itemCount = 5,
88
this.spacing = 0.0,
99
this.rating = 0.0,
@@ -15,9 +15,7 @@ class GFRating extends StatelessWidget {
1515
this.filledIcon,
1616
this.halfFilledIcon,
1717
this.allowHalfRating = true,
18-
}) {
19-
assert(this.rating != null);
20-
}
18+
}) : assert(rating != null);
2119

2220
/// defines total number of rating items
2321
final int itemCount;
@@ -61,7 +59,7 @@ class GFRating extends StatelessWidget {
6159
size: itemSize,
6260
);
6361
} else if (index > rating - (allowHalfRating ? 0.5 : 1.0) &&
64-
index < rating) {
62+
index <= rating) {
6563
icon = Icon(
6664
halfFilledIcon != null ? halfFilledIcon : Icons.star_half,
6765
color: color ?? Theme.of(context).primaryColor,
@@ -77,9 +75,10 @@ class GFRating extends StatelessWidget {
7775

7876
return GestureDetector(
7977
onTap: () {
80-
if (onRatingChanged != null) onRatingChanged(index + 1.0);
78+
if (onRatingChanged != null) {
79+
onRatingChanged(index + 1.0);
80+
}
8181
},
82-
// onHorizontalDragStart: ,
8382
child: icon,
8483
);
8584
}
@@ -88,9 +87,12 @@ class GFRating extends StatelessWidget {
8887
Widget build(BuildContext context) => Material(
8988
color: Colors.transparent,
9089
child: Wrap(
91-
alignment: WrapAlignment.center,
92-
spacing: spacing,
93-
children: List.generate(
94-
itemCount, (index) => buildRatingBar(context, index))),
90+
alignment: WrapAlignment.center,
91+
spacing: spacing,
92+
children: List.generate(
93+
itemCount,
94+
(index) => buildRatingBar(context, index),
95+
),
96+
),
9597
);
9698
}

0 commit comments

Comments
 (0)