Skip to content

codezero93/scrollable_form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrollable_form

A Flutter package that auto scrolls to the first invalid field when form validation fails.


Usage

1. Replace Form with ScrollableForm

final _formKey = GlobalKey<ScrollableFormState>();

ScrollableForm(
  key: _formKey,
  child: SingleChildScrollView(
    child: Column(children: [ ... ]),
  ),
)

2. Call validateAndScroll() on submit

void _submit() {
  if (_formKey.currentState!.validateAndScroll()) {
  }
}

Customise the scroll animation

ScrollableForm(
  key: _formKey,
  scrollDuration: const Duration(milliseconds: 500),
  scrollCurve: Curves.easeInOutCubic,
  scrollAlignment: 0.2, // 0.0 = top of viewport, 1.0 = bottom
  child: ...,
)

Requirements

  • Flutter ≥ 3.10.0
  • Dart ≥ 3.0.0

About

A Flutter Form wrapper that auto scrolls to the first invalid field when form validation fails.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages