flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

FormBuilderRangeSlider terrible performance when in scrollable container

Open rensvis opened this issue 2 years ago • 1 comments

Using FormBuilderRangeSlider widget inside a SingleChildScrollView widget that has physics: const AlwaysScrollableScrollPhysics() leads to performance issues when trying to drag the handles around. It seems to interfere with scrolling up and down the page (or the scrollable container). Interestingly, FormBuilderSlider does not lead to any issues.

ezgif com-gif-maker

Flutter version: 3.0.3 Plugin version: 7.3.1

Example:

import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:solli/model/models/job.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';

class EditJobScreen extends StatelessWidget {
  EditJobScreen({
    Key? key,
  }) : super(key: key);

  final _formKey = GlobalKey<FormBuilderState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Test')),
      body: Scrollbar(
        child: SingleChildScrollView(
          physics: const AlwaysScrollableScrollPhysics(),
          child: Padding(
            padding: const EdgeInsets.symmetric(
              vertical: 20.0,
              horizontal: 20.0,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                FormBuilder(
                  key: _formKey,
                  autovalidateMode: AutovalidateMode.disabled,
                  child: Column(children: [
                    FormBuilderSwitch(
                      name: 'active',
                      initialValue: true,
                      title: Text(
                        'Active',
                        style: Theme.of(context).textTheme.headline5,
                      ),
                      decoration: const InputDecoration(
                        border: InputBorder.none,
                      ),
                    ),
                    FormBuilderRangeSlider(
                      name: 'hours',
                      min: 0,
                      max: 40,
                      // divisions: 40,
                      decoration: const InputDecoration(
                        border: InputBorder.none,
                        labelText: 'Hours per week',
                      ),
                      initialValue: const RangeValues(0.0, 40.0),
                    ),
                    FormBuilderSlider(
                      initialValue: 1,
                      min: 0,
                      max: 40,
                      name: '',
                    ),
                    Container(
                      height: 800,
                      color: Colors.grey,
                    )
                  ]),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

rensvis avatar Jun 23 '22 16:06 rensvis

Hi @rensvis. Thanks for your contribution. Seems a interesting bug to take a look.

Related to this file, maybe is related with some Flutter bug or a widget arrange in this package.

Feel free to comment or open a PR if you solve this error.

deandreamatias avatar Jun 24 '22 15:06 deandreamatias