1
0
mirror of https://github.com/go-vikunja/app synced 2024-05-29 00:36:49 +00:00
app-mirror-github/lib/utils/calculate_item_position.dart
Denys Vitali 056b2d72c9
chore: format code with dart format (#71)
This PR formats all code with dart format and adds a step to the CI so that it will be checked on every push and PR.
2024-04-05 22:36:56 +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;
}