flutter_shape_matcher 0.0.3
flutter_shape_matcher: ^0.0.3 copied to clipboard
This Flutter package serves as a vital parental gate for children under 5, combining entertainment and education.
import 'package:flutter/material.dart';
import 'package:flutter_shape_matcher/flutter_shape_matcher.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const SampleScreen(),
);
}
}
class SampleScreen extends StatelessWidget {
const SampleScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: MediaQuery.of(context).size.height * .45,
child: ShapeMatcher(
onSuccess: () => showSnackBar(context, 'Correct'),
onFailure: () => showSnackBar(context, 'Wrong'),
),
),
)
],
),
),
);
}
/// This is a function that populate the snackbar
/// [context]: BuildContext
/// [message]: String value
void showSnackBar(BuildContext context, String message) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
scaffoldMessenger.showSnackBar(
SnackBar(
content: Text(message),
duration: const Duration(seconds: 3),
),
);
}
}