Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:freezed_annotation/freezed_annotation.dart';
- part 'health_pregnancy_model.freezed.dart';
- part 'health_pregnancy_model.g.dart';
- @freezed
- class HealthPregnancyModel with _$HealthPregnancyModel {
- factory HealthPregnancyModel({
- required final Quiz quiz,
- required final TopicPage topicPage,
- }) = _HealthPregnancyModel;
- factory HealthPregnancyModel.fromJson(Map<String, dynamic> json) =>
- _$HealthPregnancyModelFromJson(json);
- }
- @freezed
- class TopicPage with _$TopicPage {
- factory TopicPage({
- required final String headerText,
- required final String reference1,
- required final String reference2,
- required final String reference3,
- required final String subTopic1Title,
- required final String subTopic2Title,
- }) = _TopicPage;
- factory TopicPage.fromJson(Map<String, dynamic> json) =>
- _$TopicPageFromJson(json);
- }
- @freezed
- class Quiz with _$Quiz {
- factory Quiz({
- @JsonKey(fromJson: Quiz.quizFromJson, toJson: Quiz.quizToJson)
- required final List<QuizData> quiz,
- }) = _Quiz;
- factory Quiz.fromJson(Map<String, dynamic> json) => _$QuizFromJson(json);
- static quizFromJson(List<dynamic> listOfItem) => listOfItem.isEmpty
- ? []
- : listOfItem.map((item) => QuizData.fromJson(item)).toList();
- static quizToJson(List<QuizData?> items) => items.isEmpty
- ? []
- : items
- .map((item) => _$$QuizDataImplToJson(item as _$QuizDataImpl))
- .toList();
- }
- @freezed
- class QuizData with _$QuizData {
- factory QuizData({
- required final Answer answer,
- required final String question,
- }) = _QuizData;
- factory QuizData.fromJson(Map<String, dynamic> json) =>
- _$QuizDataFromJson(json);
- }
- @freezed
- class Answer with _$Answer {
- factory Answer({
- @JsonKey(
- fromJson: Answer.answerFromJson,
- toJson: Answer.answerToJson,
- )
- required final List<AnswerData> answer,
- }) = _Answer;
- factory Answer.fromJson(Map<String, dynamic> json) => _$AnswerFromJson(json);
- static answerFromJson(List<dynamic> listOfItem) => listOfItem.isEmpty
- ? []
- : listOfItem.map((item) => AnswerData.fromJson(item)).toList();
- static answerToJson(List<AnswerData?> items) => items.isEmpty
- ? []
- : items
- .map((item) => _$$AnswerDataImplToJson(item as _$AnswerDataImpl))
- .toList();
- }
- @freezed
- class AnswerData with _$AnswerData {
- factory AnswerData({
- required final bool rightStatus,
- required final String text,
- }) = _AnswerData;
- factory AnswerData.fromJson(Map<String, dynamic> json) =>
- _$AnswerDataFromJson(json);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement