Created
March 10, 2020 13:13
-
-
Save geeksilva97/fd43a198b8cb78af07efbc9846b2a8fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class RatingDialog extends StatefulWidget { | |
@override | |
_RatingDialogState createState() => _RatingDialogState(); | |
} | |
class _RatingDialogState extends State<RatingDialog> { | |
int _stars = 0; | |
Widget _buildStar(int starCount) { | |
return InkWell( | |
child: Icon( | |
Icons.star, | |
// size: 30.0, | |
color: _stars >= starCount ? Colors.orange : Colors.grey, | |
), | |
onTap: () { | |
setState(() { | |
_stars = starCount; | |
}); | |
}, | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return AlertDialog( | |
title: Center(child: Text('Rate this post'),), | |
content: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
_buildStar(1), | |
_buildStar(2), | |
_buildStar(3), | |
_buildStar(4), | |
_buildStar(5), | |
], | |
), | |
actions: <Widget>[ | |
FlatButton( | |
child: Text('CANCEL'), | |
onPressed: Navigator.of(context).pop, | |
), | |
FlatButton( | |
child: Text('OK'), | |
onPressed: () { | |
Navigator.of(context).pop(_stars); | |
}, | |
) | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment