question_frame 1.0.2 question_frame: ^1.0.2 copied to clipboard
Questionnaire package for dynamic form. The Package aims to provide custom implementation of many type of widget to ease the form making.
example/question_frame_example.dart
import 'package:flutter/material.dart';
import 'package:question_frame/question_frame.dart';
import 'package:question_frame/src/model/option.dart';
final sampleQuestion = FrameQuestion(
id: 1,
mId: 1,
qKey: 'name',
qLabel: "Enter Your name",
qType: 'stringInput',
qMandatory: true,
mandatoryMessage: "Name is required for further interactions.",
onLoad: "",
onLoadMsg: '',
onActivity: "validateName",
onActivityMsg: "not a valid name",
qImage: '',
qAudio: '',
qVideo: '',
options: [
FrameOption(1, 1, -1, 2),
],
qHint: "Write your name below",
);
void main() {
final Map<FrameQuestion, FrameUserResponse> questionResponseMap = {};
final List<FrameQuestion> frameQuestion = [
sampleQuestion,
sampleQuestion.copyWith(
id: 2,
qKey: 'age',
onActivity: 'validateAge',
onActivityMsg: 'Not a Valid age',
qType: 'intInput'),
];
questionResponseMap.addEntries(
frameQuestion.map(
(question) => MapEntry(
question,
FrameUserResponse(
qId: question.id,
qType: question.qType,
options: question.options,
tag: question.qKey,
),
),
),
);
runApp(
MaterialApp(
home: FrameWidget(
questionResponseMap: questionResponseMap,
),
),
);
}