Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacosTextField expand with ResizablePane crashes #413

Closed
robaolana opened this issue Apr 16, 2023 · 2 comments · Fixed by #420
Closed

MacosTextField expand with ResizablePane crashes #413

robaolana opened this issue Apr 16, 2023 · 2 comments · Fixed by #420
Assignees
Labels
bug Something isn't working
Milestone

Comments

@robaolana
Copy link

robaolana commented Apr 16, 2023

Description

A MacosTextField wrapped with Resizable Pane with expand, no maxlines crashes with the error '''FlutterError (The Scrollbar's ScrollController has no ScrollPosition attached.
A Scrollbar cannot be painted without a ScrollPosition.
The Scrollbar attempted to use the provided ScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.When providing your own ScrollController, ensure both the Scrollbar and the Scrollable widget use the same one.)'''

Use textfield with generic code like this:

ResizablePane(
  minSize: 50,
  startSize: 60,
  resizableSide: ResizableSide.top,
  maxSize: MediaQuery.of(context).size.height / 2.5,
  builder: (_, __) {
    return MacosTextField(
      prefix: MacosIcon(CupertinoIcons.money_dollar),
      placeholder: 'Type some text here',
      expands: true,
      maxLines: null,
      showCursor: true,
      clearButtonMode: OverlayVisibilityMode.always,
    );
  },
),
@robaolana robaolana added the bug Something isn't working label Apr 16, 2023
@stMerlHin
Copy link
Contributor

stMerlHin commented Apr 16, 2023

Hey @robaolana, I can actually reproduce the issue.

ResizablePane has an internal Scrollable so making any widget a child of ResisablePane is some way wrapping it with Scrollable. You are supposed to give the scrollController of the ResizablePane.builder to the main widget which has a scroll behaviour in your widget tree. Since the MacosTextField like material TextField content can be scrolled when it overflows the view port it has a scroll behaviour.

Also it should not crash the app, you should just have the error stack trace in your console when scrolling the content of the MacosTextField but visually everything should seem to be working fine.

Poposal

Try this...

ResizablePane(
minSize: 50,
startSize: 60,
resizableSide: ResizableSide.top,
maxSize: MediaQuery.of(context).size.height / 2.5,
builder: (_, scrollController) {
   return MacosTextField(
       //Passing the  builder scrollController  to the [MacosTextField]
       scrollController: scrollController,
       prefix: MacosIcon(CupertinoIcons.money_dollar),
       placeholder: 'Type some text here',
       expands: true,
       maxLines: null,
       showCursor: true,
       clearButtonMode: OverlayVisibilityMode.always,
),);
},
)

@stMerlHin
Copy link
Contributor

stMerlHin commented Apr 16, 2023

@GroovinChip, Shouldn't be nice to add a property and maybe a Constructor that would allow the disabling of the scroll behavior of the Resizablepane ?

Sometimes I use scrollable widgets which don't expose their controller, so the only way to avoid this error is to wrap them inside another Scrollable widget which expose his controller.

@GroovinChip GroovinChip moved this to In Review in macos_ui Jul 3, 2023
@GroovinChip GroovinChip added this to the Version 2.0 milestone Jul 3, 2023
@GroovinChip GroovinChip modified the milestone: Version 2.0 Jul 10, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in macos_ui Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants