rating options
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||
|
||||
class RatingEmote extends StatelessWidget {
|
||||
const RatingEmote({super.key, required this.onRate});
|
||||
|
||||
final Function onRate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RatingBar.builder(
|
||||
initialRating: 0,
|
||||
itemCount: 3,
|
||||
itemSize: 80,
|
||||
itemBuilder: (context, index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return const Icon(
|
||||
Icons.sentiment_very_dissatisfied,
|
||||
color: Color.fromRGBO(236, 91, 91, 1.0),
|
||||
);
|
||||
case 1:
|
||||
return const Icon(
|
||||
Icons.sentiment_neutral,
|
||||
color: Color.fromRGBO(236, 173, 91, 1.0),
|
||||
);
|
||||
case 2:
|
||||
return const Icon(
|
||||
Icons.sentiment_very_satisfied,
|
||||
color: Color.fromRGBO(95, 175, 72, 1.0),
|
||||
);
|
||||
}
|
||||
return const Icon(Icons.error);
|
||||
},
|
||||
|
||||
onRatingUpdate: (rating) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||
|
||||
class RatingStars extends StatelessWidget {
|
||||
const RatingStars({super.key, required this.onRate});
|
||||
|
||||
final Function onRate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RatingBar.builder(
|
||||
initialRating: 0,
|
||||
minRating: 1,
|
||||
itemSize: 80,
|
||||
direction: Axis.horizontal,
|
||||
allowHalfRating: false,
|
||||
itemCount: 5,
|
||||
itemPadding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
itemBuilder: (context, index) {
|
||||
return Icon(
|
||||
Icons.star_rounded,
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
);
|
||||
},
|
||||
onRatingUpdate: (rating) {
|
||||
onRate();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user