Skip to content

Commit

Permalink
code analyzed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip Kakadiya authored and Sandip Kakadiya committed Jan 31, 2020
1 parent dd8751f commit fe1fe33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ analyzer:
- getflutter_app
- getflutter-app-kit
- getflutter-web-kit
- test/.test_coverage.dart

linter:
rules:
Expand Down
12 changes: 6 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class _MyHomePageState extends State<MyHomePage>
'Xamarin2',
];

var rating = 3.5;
double rating = 3.5;

@override
Widget build(BuildContext context) => Scaffold(
Expand All @@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage>
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
stops: [0.1, 0.5, 0.7, 0.9],
stops: const [0.1, 0.5, 0.7, 0.9],
colors: [
Colors.teal[800],
Colors.teal[600],
Expand Down Expand Up @@ -234,21 +234,21 @@ class _MyHomePageState extends State<MyHomePage>
GFCard(
content: Column(
children: <Widget>[
GFTypography(
const GFTypography(
text: 'Toast',
type: GFTypographyType.typo6,
),
SizedBox(
const SizedBox(
height: 20,
),
SizedBox(
const SizedBox(
height: 20,
),
GFToast(
text: 'Happy New Year',
button: GFButton(
onPressed: () {
print("dfr");
print('dfr');
},
text: 'OK',
type: GFButtonType.outline,
Expand Down
26 changes: 14 additions & 12 deletions lib/components/rating/gf_rating.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';

typedef void RatingChangeCallback(double rating);
typedef RatingChangeCallback = void Function(double rating);

class GFRating extends StatelessWidget {
GFRating({
const GFRating({
this.itemCount = 5,
this.spacing = 0.0,
this.rating = 0.0,
Expand All @@ -15,9 +15,7 @@ class GFRating extends StatelessWidget {
this.filledIcon,
this.halfFilledIcon,
this.allowHalfRating = true,
}) {
assert(this.rating != null);
}
}) : assert(rating != null);

/// defines total number of rating items
final int itemCount;
Expand Down Expand Up @@ -61,7 +59,7 @@ class GFRating extends StatelessWidget {
size: itemSize,
);
} else if (index > rating - (allowHalfRating ? 0.5 : 1.0) &&
index < rating) {
index <= rating) {
icon = Icon(
halfFilledIcon != null ? halfFilledIcon : Icons.star_half,
color: color ?? Theme.of(context).primaryColor,
Expand All @@ -77,9 +75,10 @@ class GFRating extends StatelessWidget {

return GestureDetector(
onTap: () {
if (onRatingChanged != null) onRatingChanged(index + 1.0);
if (onRatingChanged != null) {
onRatingChanged(index + 1.0);
}
},
// onHorizontalDragStart: ,
child: icon,
);
}
Expand All @@ -88,9 +87,12 @@ class GFRating extends StatelessWidget {
Widget build(BuildContext context) => Material(
color: Colors.transparent,
child: Wrap(
alignment: WrapAlignment.center,
spacing: spacing,
children: List.generate(
itemCount, (index) => buildRatingBar(context, index))),
alignment: WrapAlignment.center,
spacing: spacing,
children: List.generate(
itemCount,
(index) => buildRatingBar(context, index),
),
),
);
}

0 comments on commit fe1fe33

Please sign in to comment.