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

onPressed problems #264

Closed
sigjak opened this issue Nov 21, 2021 · 3 comments
Closed

onPressed problems #264

sigjak opened this issue Nov 21, 2021 · 3 comments

Comments

@sigjak
Copy link

sigjak commented Nov 21, 2021

In version 1.1.0 the onPressed function seems to be running on build but not when pressed. In a ListView.builder with a simple function, which prints index of list when run, the index is printed for the entire list on build but not when the slidable is pressed.

@sigjak
Copy link
Author

sigjak commented Nov 21, 2021

I assumed a function should be called in onPressed but that is not the case. My misunderstanding. Maybe the readme could be more informative.

@sigjak sigjak closed this as completed Nov 21, 2021
@aaronkelton
Copy link

I had a similar problem trying to simply print. Trying to do so without a context argument raised the following error: Error: The argument type 'void Function()' can't be assigned to the parameter type 'void Function(BuildContext)?'. I found this behavior to be surprising. I did not expect it.

endActionPane: ActionPane(
  children: [
    SlidableAction(
      onPressed: () => print('hey'),
      label: 'Test',
    ),
  ],
  motion: ScrollMotion(),
),

To fix the error, you can pass context or really just some dummy throw away variable, like the underscore _, e.g.

endActionPane: ActionPane(
  children: [
    SlidableAction(
      onPressed: (_) => print('hey'),
      label: 'Test',
    ),
  ],
  motion: ScrollMotion(),
),

@leonacky
Copy link

I had a similar problem trying to simply print. Trying to do so without a context argument raised the following error: Error: The argument type 'void Function()' can't be assigned to the parameter type 'void Function(BuildContext)?'. I found this behavior to be surprising. I did not expect it.

endActionPane: ActionPane(
  children: [
    SlidableAction(
      onPressed: () => print('hey'),
      label: 'Test',
    ),
  ],
  motion: ScrollMotion(),
),

To fix the error, you can pass context or really just some dummy throw away variable, like the underscore _, e.g.

endActionPane: ActionPane(
  children: [
    SlidableAction(
      onPressed: (_) => print('hey'),
      label: 'Test',
    ),
  ],
  motion: ScrollMotion(),
),

still get error

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

3 participants