패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.1

flutter_survey

조건부 질문을 포함한 동적 설문조사/데이터 수집의 생성 및 상태를 처리하는 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
133
좋아요
52
Pub 점수
140

패키지 설치

flutter pub add flutter_survey

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flutter Survey는 Flutter 애플리케이션에서 상호작용 가능한 설문조사 및 데이터 수집을 위해 설계된 동적 폼 패키지입니다. 조건부 로직을 지원하여 이전 답변에 따라 질문이 나타나거나 사라질 수 있습니다. 패키지는 설문 상태를 효율적으로 관리하여 여러 플랫폼 간의 원활한 탐색과 데이터 처리를 가능하게 합니다. 사용자 피드백 수집, 평가 수행, 분기 논리를 가진 구조화된 입력 수집에 이상적입니다. Android, iOS, Web, macOS, Windows, Linux 대상 앱에 원활하게 통합됩니다.

사용 사례

  • 사용자 피드백 수집
  • 인터랙티브 평가
  • 동적 데이터 입력 양식
  • 브랜치형 설문지 워크플로우
  • 모바일 및 웹 데이터 설문조사

주요 기능

  • 조건부 질문 렌더링
  • 설문 조사용 상태 관리
  • 크로스 플랫폼 지원
  • Flutter와의 간편한 통합
  • 복잡한 분기 로직 지원
  • 재사용 가능한 설문 구성 요소

적합한 대상

  • 인터랙티브 폼을 개발하는 개발자
  • 적응형 질문 흐름이 필요한 애플리케이션
  • 연구 또는 분석을 위한 데이터 수집 도구
  • 다중 플랫폼 설문 앱
  • 사용자 경험 중심의 데이터 입력 인터페이스

고려 사항

  • 조건 논리 설계에 대한 이해가 필요합니다
  • 복잡한 레이아웃의 경우 맞춤 스타일링이 필요할 수 있습니다
  • 기본 요구 사항을 초과한 내장 검증은 제한적
  • 매우 맞춤형 UI가 아닌 중간 복잡도의 설문조사에 적합

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Survey Logo

Pub License: MIT style: flutter lints License: MIT

Flutter Survey Logo Flutter Survey

Inspired by Google Forms

A simple yet powerful package that handles the creation of a dynamic questionnaire/research survey with conditional questions.
Have you ever wanted to implement a form/questionnaire/survey like the ones you see on Google forms?
Have you ever wanted to implement conditional questions that show or hide the questions that follow, based on the user's input?
This package helps you build data collection forms hassle-free.

Screenrecorder-2021-05-11-20-23-21-153

📋 Features

:heavy_check_mark: Eliminates boilerplate code for surveys.
:heavy_check_mark: Implement Conditional/Single Choice/Multiple Choice questions.
:heavy_check_mark: Intuitively construct your own questions with infinite nesting.
:heavy_check_mark: Customize it by creating your own form widgets from scratch using the builder method.
:heavy_check_mark: Add your own properties for your custom widgets.
:heavy_check_mark: Supports validation using the Form widget
:heavy_check_mark: Implicitly supports Dark theme.

🔮 Next Update

:heavy_check_mark: Supports Internationalization.
:heavy_check_mark: Supports custom regex validation
:heavy_check_mark: Supports various formats of input (Date Picker, File Upload, Slider etc)
:heavy_check_mark: Track progress

⚙️ Installation

This project requires the latest version of Dart. You can download the latest and greatest here.

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
    flutter_survey: '^1.0.1'
2. Install it

You can install packages from the command line:

$ pub get
..

Alternatively, your editor might support pub. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_survey/survey.dart';

📖 Usage

First, you must initialize the question structure where you specify the type of questions and their possible answers, if any. You can also nest questions to form conditional questions. You can even mark them as mandatory. This can be either in json format fetched from the server or can be constructed using the [Question] model provided as part of this package. The structure is intuitive and determines the flow of the form.

Types of questions

The Questions are classified based on the kind of input they take.

Text Input Question

As the name suggests here the answer is not limited to any specific choice. The answer to this question can be typed in by the user, single line or multiline. Setting the answerChoice variable to null or simply leaving it altogether gives you this.

Question(
 question: "What is your name?",
)
Single Choice Question

Here, Radio Buttons are used as input. You define the possible answer choices as a Map, with the keys being the answer choices. Note that the value of the corresponding keys happen to be null. This is because they don't have an associated list of questions that follow it.

 Question(
   question: 'Do you like drinking coffee?',
   answerChoices: {
     "Yes": null,
     "No": null,
   },
 ),
Multiple Choice Question

Here, Checkboxes are used as input. Just like the Single Choice Questions, You define the possible answer choices as a Map with the keys being the answer choices. Note that even here the value of the corresponding keys happen to be null for the same reason as Single Choice Questions. The difference here is that you set isSingleChoice to false.

Question(
  isSingleChoice: false,
  question: 'What are the brands that you have tried?',
  answerChoices: {
    "Nestle": null,
    "Starbucks": null,
    "Coffee Day": null,
  },
),
Conditional/Nested Questions

This is where you define questions that follow based on the answer of the question prior to it. The values of the keys defined in the answerChoices field determines the flow. For example here, if the user were to choose "Yes" to "Do you like drinking coffee", the user would be confronted with another question "What are the brands you've tried?" followed by more nesting.


 Question(
   isMandatory: true,
   question: 'Do you like drinking coffee?',
   answerChoices: {
     "Yes": [
       Question(
           singleChoice: false,
           question: "What are the brands that you've tried?",
           answerChoices: {
             "Nestle": null,
             "Starbucks": null,
             "Coffee Day": [
               Question(
                 question: "Did you enjoy visiting Coffee Day?",
                 isMandatory: true,
                 answerChoices: {
                   "Yes": [
                     Question(
                       question: "Please tell us why you like it",
                     )
                   ],
                   "No": [
                     Question(
                       question: "Please tell us what went wrong",
                     )
                   ],
                 },
               )
             ],
           })
     ],
     "No": [
       Question(
         question: "Do you like drinking Tea then?",
         answerChoices: {
           "Yes": [
             Question(
                 question: "What are the brands that you've tried?",
                 answerChoices: {
                   "Nestle": null,
                   "ChaiBucks": null,
                   "Indian Premium Tea": [
                     Question(
                       question: "Did you enjoy visiting IPT?",
                       answerChoices: {
                         "Yes": [
                           Question(
                             question: "Please tell us why you like it",
                           )
                         ],
                         "No": [
                           Question(
                             question: "Please tell us what went wrong",
                           )
                         ],
                       },
                     )
                   ],
                 })
           ],
           "No": null,
         },
       )
     ],
   },
 ),
A full question structure represented as a List:
 List<Question> _initialData = [
  Question(
    isMandatory: true,
    question: 'Do you like drinking coffee?',
    answerChoices: {
      "Yes": [
        Question(
            singleChoice: false,
            question: "What are the brands that you've tried?",
            answerChoices: {
              "Nestle": null,
              "Starbucks": null,
              "Coffee Day": [
                Question(
                  question: "Did you enjoy visiting Coffee Day?",
                  isMandatory: true,
                  answerChoices: {
                    "Yes": [
                      Question(
                        question: "Please tell us why you like it",
                      )
                    ],
                    "No": [
                      Question(
                        question: "Please tell us what went wrong",
                      )
                    ],
                  },
                )
              ],
            })
      ],
      "No": [
        Question(
          question: "Do you like drinking Tea then?",
          answerChoices: {
            "Yes": [
              Question(
                  question: "What are the brands that you've tried?",
                  answerChoices: {
                    "Nestle": null,
                    "ChaiBucks": null,
                    "Indian Premium Tea": [
                      Question(
                        question: "Did you enjoy visiting IPT?",
                        answerChoices: {
                          "Yes": [
                            Question(
                              question: "Please tell us why you like it",
                            )
                          ],
                          "No": [
                            Question(
                              question: "Please tell us what went wrong",
                            )
                          ],
                        },
                      )
                    ],
                  })
            ],
            "No": null,
          },
        )
      ],
    },
  ),
  Question(
      question: "What age group do you fall in?",
      isMandatory: true,
      answerChoices: const {
        "18-20": null,
        "20-30": null,
        "Greater than 30": null,
      })
];
Pass the list of questions to the ConditionalQuestions Widget.

This is the main widget that handles the form. The list of questions constructed above are passed to the initialData parameter. The onNext callback function is an optional parameter that is called with the current state of the survey, which is a List of QuestionResult objects.

         Survey(
          initialData: _surveyData,
          onNext:(questionResults){
              print(questionResults);
              //store the result
          },
        )

🤝 Contributing

Help make this package more useful and serve the needs of the community by reporting bugs, submitting feedback and/or opening a PR.

ℹ️ About me

Visit my LinkedIn at https://www.linkedin.com/in/michel98

카테고리

의존성

의존성 목록 5 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.