Closed gmarizy closed 1 year ago
Hello @gmarizy That should not happen I will fix this, thank you for reporting the issue
I cannot reproduce the issue. Can you show me the code you have? And did this happen on iOS or Android? @gmarizy
I only have an Android at hand now, I can't confirm for iOS.
I made a sample:
import 'package:flutter/material.dart';
import 'package:flutter_reorderable_grid_view/widgets/reorderable_builder.dart';
class ShowcaseScreen extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
body: Center(
child: ShowcaseWidget(),
),
);
}
class ShowcaseWidget extends StatelessWidget {
static const _max = 9;
final ValueNotifier<List<String>> notifier = ValueNotifier(["A", "B", "C", "D"]);
ShowcaseWidget({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) => ValueListenableBuilder<List<String>>(
valueListenable: notifier,
builder: (context, items, _) {
return ReorderableBuilder(
builder: (children) => GridView(
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 16,
crossAxisSpacing: 16,
childAspectRatio: 9 / 16,
),
children: children,
),
enableLongPress: false,
enableScrollingWhileDragging: false,
lockedIndices: [for (int index = items.length; index < _max; index++) index],
onReorder: (block) {
notifier.value = block(items) as List<String>;
},
children: List.generate(
_max,
(index) => index < items.length
? Card(
key: Key("item:$index"),
clipBehavior: Clip.antiAlias,
child: Center(
child: Text(items[index]),
),
)
: Card(key: Key("filler:$index")),
),
);
}
);
}
Ah I see, this bug exists already since a longer time, I fix it and release 5.0.0-dev.10
@gmarizy
I released 5.0.0-dev.10
, this issue should be fixed, thanks again for pointing it out @gmarizy
I confirm problem is fixed. Thank you for your reactivity !
In 5.0.0-dev.9, I can move locked indices which result in errors like this: RangeError (end): Invalid value: Not in inclusive range 1..2: 7. Error thrown while routing a pointer event. RangeError.checkValidRange [errors.dart:365] List.sublist [growable_array.dart:84] ReorderableDragAndDropController.reorderList [reorderable_drag_and_drop_controller.dart:392] _ReorderableBuilderState._finishDragging. [reorderable_builder.dart:462]