mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 19:03:47 +02:00
The input check widget callback now has an id of the inputfield. The ability to set the height of the carousel input field. Some inputcontroller have an onsubmit of the inputfield supports it.
82 lines
3.1 KiB
Dart
82 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// The options used to set parameters to a [FlutterForm].
|
|
///
|
|
/// The pages determine what pages the pageview will contain via a [List] of [FlutterFormPage]s.
|
|
///
|
|
/// Using a checkpage gives the ability for the user to check all input values before commiting by [CheckPage].
|
|
/// If [checkPage] is null no check page will be shown.
|
|
///
|
|
/// [nextButton] and [backButton] are both a way to give controls to user.
|
|
/// Both are just plain widgets used in a [Stack]. So the widgets can be aligned where ever.
|
|
/// The formcontroller of [FlutterForm] should be used to give control to the widgets/buttons.
|
|
///
|
|
/// [onFinished] and [onNext] are both callbacks which give the users results.
|
|
/// [onNext] is called when the user goes to the next page.
|
|
/// [onFinished] is called when the form is finished. When checkpage is set [onFinished] is called when the checkpage is finished.
|
|
///
|
|
/// [scrollDirection] can be set to change the Axis on which the pageview slides. Defaults to horizontal.
|
|
///
|
|
/// [scrollPhysics] can be set to set the scroll phyisics of the scroll views in each page. Default to [ClampingScrollPhysics].
|
|
class FlutterFormOptions {
|
|
final List<FlutterFormPage> pages;
|
|
|
|
final CheckPage? checkPage;
|
|
final Widget Function(int pageNumber, bool checkingPages)? nextButton;
|
|
final Widget Function(int pageNumber, bool checkingPages, int pageAmount)?
|
|
backButton;
|
|
final void Function(Map<int, Map<String, dynamic>>) onFinished;
|
|
final void Function(int pageNumber, Map<String, dynamic>) onNext;
|
|
final Axis scrollDirection;
|
|
final ScrollPhysics? scrollPhysics;
|
|
|
|
const FlutterFormOptions({
|
|
required this.pages,
|
|
this.checkPage,
|
|
this.nextButton,
|
|
this.backButton,
|
|
required this.onFinished,
|
|
required this.onNext,
|
|
this.scrollDirection = Axis.horizontal,
|
|
this.scrollPhysics,
|
|
});
|
|
}
|
|
|
|
/// The defines every page in a [FlutterForm].
|
|
class FlutterFormPage {
|
|
final Widget child;
|
|
|
|
FlutterFormPage({
|
|
required this.child,
|
|
});
|
|
}
|
|
|
|
/// [CheckPage] is used to set a check page at the end of a [FlutterForm].
|
|
/// A [CheckPage] is a page where the user can check all input values before commiting.
|
|
///
|
|
/// [title] is the widget shown at the top of the page.
|
|
///
|
|
/// [mainAxisAlignment] is the alignment of the check widgets.
|
|
///
|
|
/// [inputCheckWidget] determines how every input is represented on the page.
|
|
/// [title] is the value given in the input.
|
|
/// This input can be modified by setting the [checkPageTitle] of that input controller.
|
|
///
|
|
/// Same for the [description] but if the description is not set in the input controller no description will be given.
|
|
///
|
|
/// [onPressed] can be set so that when the user triggers it the user will be sent back to the page including the input.
|
|
/// Here the user can modify the input and save it. Afterwards the user will be sent back to the check page.
|
|
class CheckPage {
|
|
final Widget? title;
|
|
final MainAxisAlignment mainAxisAlignment;
|
|
final Widget Function(
|
|
String id, String title, String? description, Function onPressed)?
|
|
inputCheckWidget;
|
|
|
|
const CheckPage({
|
|
this.title,
|
|
this.inputCheckWidget,
|
|
this.mainAxisAlignment = MainAxisAlignment.start,
|
|
});
|
|
}
|