Closed dxps closed 5 years ago
Sorry, my bad, silly question ... 😄 Solution is to just declare the 'extended' function like this:
myBloc = BlocProvider.of<MyCustomBloc>(context);
return ReorderableList(
onReorder: (itemKey, newPositionKey) => _onReorder(itemKey, newPositionKey, myBloc),
...
Hi Matej,
I want to use a BLoC (concretely, I am using the
flutter_bloc
package) inside theonReorder
callback in order to 'announce' the changes and persist them.But I would need to have access to the
BuildContext
to get the BLoC using something such asBlocProvider.of<MyCustomBloc>(context)
. So, in a StatelessWidget, a concrete implemenetation ofonReorder
callback should have this context as parameter as well:Of course, for the moment, a StatefulWidget can be used to just store the BLoC retrieved from hierarchy in its state.
What do you think?
Thanks!