-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Step / Custom Slider #131
Comments
I have defined the following as a custom step in a // avoid collisions on Step class
import 'package:survey_kit/survey_kit.dart' as k;
class CustomScaleStep extends k.Step {
final sliderKey = GlobalKey<SliderTextState>();
@override
Widget createView({required k.QuestionResult? questionResult}) {
return k.StepView(
step: k.QuestionStep(
showAppBar: false,
answerFormat: const k.IntegerAnswerFormat(
defaultValue: 5,
)),
title: const Text('title'),
child: SliderText(key: sliderKey), // custom component
resultFunction: () => k.IntegerQuestionResult(
id: k.Identifier(id: 'identifier'),
startDate: DateTime.now(),
endDate: DateTime.now(),
valueIdentifier: 'valueIdentifier',
result: sliderKey.currentState!.sliderCurrentValue.toInt()));
}
@override
Map<String, dynamic> toJson() {
return {};
}
} The |
With the following custom Step: // avoid collision with material Step
import 'package:survey_kit/survey_kit.dart' as sk;
class CustomScaleStep extends sk.Step {
final sliderKey = GlobalKey<SliderTextState>();
@override
Widget createView({required sk.QuestionResult? questionResult}) {
return sk.StepView(
step: sk.QuestionStep(
// showAppBar: false,
answerFormat: const sk.IntegerAnswerFormat(
defaultValue: 5,
)),
title: const Text('title'),
child: SliderText(key: sliderKey),
resultFunction: () {
print('result ${sliderKey.currentState!.sliderCurrentValue.toInt()}');
return sk.IntegerQuestionResult(
id: sk.StepIdentifier(),
startDate: DateTime.now(),
endDate: DateTime.now(),
valueIdentifier:
sliderKey.currentState!.sliderCurrentValue.toInt().toString(),
result: sliderKey.currentState!.sliderCurrentValue.toInt(),
);
});
}
@override
Map<String, dynamic> toJson() {
return {};
}
} and in the enclosing task, this navigation rule is added: task.addNavigationRule(
forTriggerStepIdentifier: task.steps[1].stepIdentifier,
navigationRule:
sk.ConditionalNavigationRule(resultToStepIdentifierMapper: (input) {
if ((input == '1') || (input == '2')) {
return null;
}
return task.steps[0].stepIdentifier;
}),
); in the It seems that the choice of naming between |
I am also interested in building a CustomStep that will play a video and then move to the next step. |
@pmagnuson Hi, are you using CustomStep via json? How are you able to add the json parser for the custom step in survey_kit? |
@adar2378 I am no longer using this library. |
I am finding it quite difficult to navigate the documentation of CustomResult & CustomStep.
My goal is to create a custom Slider instead of ScaledAnswerFormat.
Any examples would be greatly appreciated.
The text was updated successfully, but these errors were encountered: