quiz_package 0.2.1+1
quiz_package: ^0.2.1+1 copied to clipboard
A package providing quiz-related widgets and utilities.
🧠 quiz_package #
quiz_package est un package Flutter permettant d'intégrer une mécanique de quiz dans votre application Owlnext, avec ou sans clé de participation API. Il fournit un widget principal QuizEngine configurable.
🚀 Installation #
Ajoutez ceci à votre pubspec.yaml :
dependencies:
quiz_package:
quiz-package: {{pubdev_version}}
#path: /srv/owlnext/quiz-package
#git:
#url: https://github.com/owlnext-fr/quiz-package
📦 Import
import 'package:quiz_package/quiz_package.dart';
🧪 Exemple d'utilisation
@override
Widget build(BuildContext context) {
if (isPartcipationKeyReachable) {
return QuizEngine(
useParticipationKey: true,
services: QuizEngineServices(
getParticipationDetails: () async {
return await ParticipationService().getParticipationDetails();
},
putParticipationResponses: ({required data}) async {
return await ParticipationService().putParticipationResponses(data: data);
},
),
errors: QuizEngineErrorLogger(
captureException: (throwable, {scope, stackTrace}) async {
Sentry.captureException(throwable, stackTrace: stackTrace, withScope: (scopeContext) {
scopeContext.setTag(
'QuizEngine -> scope: ${scope ?? "Not provided"}',
'error: $throwable, trace: $stackTrace',
);
});
},
),
);
}
// Fallback sans clé de participation
return QuizEngine(
useParticipationKey: false,
quizTemplate: fallbackQuiz, //Passer directement le template de formulaire
services: QuizEngineServices(),
errors: QuizEngineErrorLogger(
captureException: (throwable, {scope, stackTrace}) async {
Sentry.captureException(throwable, stackTrace: stackTrace, withScope: (scopeContext) {
scopeContext.setTag(
'QuizEngine -> scope: ${scope ?? "Not provided"}',
'error: $throwable, trace: $stackTrace',
);
});
},
),
);
}