1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-01 02:06:51 +00:00
app-mirror-github/lib/utils/calculate_item_position.dart
2024-04-05 14:52:50 +02:00

22 lines
526 B
Dart

import 'dart:math';
double calculateItemPosition({double? positionBefore, double? positionAfter}) {
// only
if (positionBefore == null && positionAfter == null) {
return 0;
}
// first
if (positionBefore == null && positionAfter != null) {
return positionAfter / 2;
}
// last
if (positionBefore != null && positionAfter == null) {
return positionBefore + pow(2.0, 16.0);
}
// in the middle (positionBefore != null && positionAfter != null)
return (positionBefore! + positionAfter!) / 2;
}