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

[linked_scroll_controller] error when being set via setState #539

Open
deathblade666 opened this issue Sep 2, 2024 · 0 comments
Open

[linked_scroll_controller] error when being set via setState #539

deathblade666 opened this issue Sep 2, 2024 · 0 comments

Comments

@deathblade666
Copy link

Problem description

linked_scroll_controller

Receive this error when trying do .addAndGet() via setState() instead of intitState(). the purpose for me to set it via setState() is so that it can be toggleable in case user's dont want synchronized scrolling across the widgets. for application context, I'm making a Markdown editor as (top of the screen is the user's input rendered inmarkdown, bottom is a textfield) my first flutter app and the thought behind using this package is that if someone is editing a large file being able to have scroll synchronized would be helpful in making sure it renders properly as well as finding sections to edit.

Anyway, after I get this error the app and this package function as expected after a restart (thanks to sharedd preferences loading on start), however I dont think having to restart the app is good UX.

image

Steps to reproduce

Not sure what to put here so I'll just put my code snippet, this function is also called upon via initState() and thus the reason for the extra checks, as initState loads the last known settings from shared preferences.

void syncScroll (syncScrolling){
    if (syncScrolling == true) {
      setState(() {
        scrollRenderController = scrollGroup.addAndGet();
        userInputController = scrollGroup.addAndGet();
      });
    }
    if (syncScrolling == false) {
      if (userInputController.hasClients == true){
        setState(() {
          userInputController.dispose();
        });
      }
      if (scrollRenderController.hasClients == true){
        setState(() {
          scrollRenderController.dispose();
        });
      }
    }
  }

Expected behavior

to not error

Actual behavior

error (picture above)

Environment

Tested on Linux (Arch) as well as Android (pixel 6 running latest android 15 beta)

Additional details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant