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

Inconsistency with ListFieldBloc#updateFieldBlocs #346

Open
Zekfad opened this issue Feb 2, 2024 · 1 comment
Open

Inconsistency with ListFieldBloc#updateFieldBlocs #346

Zekfad opened this issue Feb 2, 2024 · 1 comment

Comments

@Zekfad
Copy link

Zekfad commented Feb 2, 2024

I've tried to use ReorderableListView with ListFieldBloc and found following inconsistency:

final shapes = ListFieldBloc<ShapePropertiesBloc, void>();

This one produces incorrect results inconsistently

  void reorderShape(int oldIndex, int newIndex) {
    final blocs = shapes.state.fieldBlocs;
    final shapeBloc = blocs.removeAt(oldIndex);
    blocs.insert(
      oldIndex < newIndex
        ? newIndex - 1
        : newIndex,
      shapeBloc,
    );
    shapes.updateFieldBlocs(blocs);
  }

This method produces correct results, but creates a junk frames due to double emit.

  void reorderShape(int oldIndex, int newIndex) {
     shapes
      ..removeFieldBlocAt(oldIndex)
      ..insertFieldBloc(
        shapeBloc,
        oldIndex < newIndex
          ? newIndex - 1
          : newIndex,
      );
  }

I suspect issue is with order of FormBlocUtils calls, because they are different if I use patch method.

@vasilich6107
Copy link

#312 (comment)

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

2 participants