flutter_emoji_feedback 0.4.0 flutter_emoji_feedback: ^0.4.0 copied to clipboard
A fully customizable widget to receive feedback from your users. Can be used to get user's mood or evaluate experience (and more !)
import 'package:flutter/material.dart';
import 'package:flutter_emoji_feedback/flutter_emoji_feedback.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Example App',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int? rating;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
EmojiFeedback(
rating: rating,
emojiPreset: handDrawnEmojiPreset,
labelTextStyle: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontWeight: FontWeight.w400),
onChanged: (value) {
setState(() => rating = value);
// Show snackbar
ScaffoldMessenger.of(context)
..clearSnackBars()
..showSnackBar(SnackBar(content: Text('$value')));
},
)
],
),
),
),
);
}
}