Added the ability to change the scroll physics of the pages' scrollview

Updated readme and changelog
This commit is contained in:
Jacques Doeleman 2022-10-11 16:35:47 +02:00
parent b17d386ff1
commit c00dba357e
4 changed files with 23 additions and 9 deletions

View file

@ -1,3 +1,9 @@
## 0.0.1 - September 29th 2022 ## 0.0.1 - September 29th 2022
- Initial release - Initial release
## 0.0.2 - October 12th 2022
- Added a multi line plain text input widget
- Ability to set the scrolldirection of the pageview
- Ability to set the scrollphysics of the pages' scrollview.

View file

@ -24,13 +24,15 @@ Flutter Form has two paramaters: options and formController. Each of these param
Options: Options:
| Parameter | Explaination | | Parameter | Explaination |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| checkPage | If this is set the form will feature a checkpage at the end so the end user can verify and alter his answers. | | checkPage | If this is set the form will feature a checkpage at the end so the end user can verify and alter his answers. |
| nextButton | The button which is put in the stack of the Form. An onTap has to be implemented and should call to the FormController. Standard call is autoNextStep(). | | nextButton | The button which is put in the stack of the Form. An onTap has to be implemented and should call to the FormController. Standard call is autoNextStep(). |
| backButton | Same as the nextButton. A widget that is put in the stack of the Form. An onTap has to be implemented and should call to the FormController. Standard call is previousStep(). | | backButton | Same as the nextButton. A widget that is put in the stack of the Form. An onTap has to be implemented and should call to the FormController. Standard call is previousStep(). |
| onFinised | The callback that will be called when the last page is finished. If checkPage is enabled this will call after the checkPage is passed. | | onFinised | The callback that will be called when the last page is finished. If checkPage is enabled this will call after the checkPage is passed. |
| onNext | The callback that is called when the user finishes a page. PageNumber is also provided. | | onNext | The callback that is called when the user finishes a page. PageNumber is also provided. |
| scrollDirection | The abilty to set the scroll direction of the forms .pageview |
| scrollPhysics | The ability to set the scroll physics of scroll views in each form page. |
FormController: FormController:

View file

@ -239,7 +239,8 @@ class _FlutterFormState extends ConsumerState<FlutterForm> {
child: fs.FormState( child: fs.FormState(
formController: _formController.getFormPageControllers()[i], formController: _formController.getFormPageControllers()[i],
child: CustomScrollView( child: CustomScrollView(
physics: const ClampingScrollPhysics(), physics: _formController._options.scrollPhysics ??
const ClampingScrollPhysics(),
slivers: [ slivers: [
SliverFillRemaining( SliverFillRemaining(
hasScrollBody: false, hasScrollBody: false,
@ -257,7 +258,8 @@ class _FlutterFormState extends ConsumerState<FlutterForm> {
widget.options.checkPage!.title!, widget.options.checkPage!.title!,
Expanded( Expanded(
child: CustomScrollView( child: CustomScrollView(
physics: const ClampingScrollPhysics(), physics: _formController._options.scrollPhysics ??
const ClampingScrollPhysics(),
slivers: [ slivers: [
SliverFillRemaining( SliverFillRemaining(
hasScrollBody: false, hasScrollBody: false,

View file

@ -16,6 +16,8 @@ import 'package:flutter/material.dart';
/// [onFinished] is called when the form is finished. When checkpage is set [onFinished] is called when the checkpage is finished. /// [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. /// [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 { class FlutterFormOptions {
final List<FlutterFormPage> pages; final List<FlutterFormPage> pages;
@ -26,6 +28,7 @@ class FlutterFormOptions {
final void Function(Map<int, Map<String, dynamic>>) onFinished; final void Function(Map<int, Map<String, dynamic>>) onFinished;
final void Function(int pageNumber, Map<String, dynamic>) onNext; final void Function(int pageNumber, Map<String, dynamic>) onNext;
final Axis scrollDirection; final Axis scrollDirection;
final ScrollPhysics? scrollPhysics;
const FlutterFormOptions({ const FlutterFormOptions({
required this.pages, required this.pages,
@ -35,6 +38,7 @@ class FlutterFormOptions {
required this.onFinished, required this.onFinished,
required this.onNext, required this.onNext,
this.scrollDirection = Axis.horizontal, this.scrollDirection = Axis.horizontal,
this.scrollPhysics,
}); });
} }