Reputation: 107
I am trying to always show scrollbar for my TextFormField. I am wrapping it a Scrollbar, but I am unable to disable the default scrollbar of the TextFormField. So I end up seeing 2 scrollbars.
I am trying to disable the scrollbar of the TextFormField using the ScrollConfiguration as suggested here for the same issue on the ListView: https://github.com/flutter/flutter/issues/99724
This is my code below. Is there any to achieve changing scrollbehaviour of the TextFormField
Center(
child: Container(
height: 300,
width: 400,
decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
padding: const EdgeInsets.all(20),
child: Scrollbar(
controller: scrollController,
thumbVisibility: true,
child: Padding(
padding: const EdgeInsets.only(right: 20.0),
child: ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
child: TextFormField(
maxLines: null,
decoration: const InputDecoration(border: InputBorder.none),
scrollController: scrollController,
),
),
),
),
),
))
Upvotes: 0
Views: 401
Reputation: 725
a solution may be to create in Custom Scroll Behavior that returning the child directly to avoid drawing the overscroll indicator.
...
child: ScrollConfiguration(
behavior: CustomScrollBehavior(),
child: TextFormField(
...
class CustomScrollBehavior extends MaterialScrollBehavior {
// Here, we're returning the child directly to avoid drawing the overscroll indicator.
@override
Widget buildScrollbar(
BuildContext context, Widget child, ScrollableDetails details) {
return child;
}
@override
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) {
return child;
}
}
Upvotes: 0