mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
35 lines
615 B
Dart
35 lines
615 B
Dart
|
import 'dart:math' as math;
|
||
|
|
||
|
import 'package:to_string/to_string.dart';
|
||
|
|
||
|
part 'progress_util.g.dart';
|
||
|
|
||
|
@toString
|
||
|
class IntProgress {
|
||
|
IntProgress(this.max) : step = max <= 0 ? 1 : 1 / max;
|
||
|
|
||
|
void next() {
|
||
|
_current = math.min(_current + 1, max);
|
||
|
}
|
||
|
|
||
|
double get progress => max <= 0 ? 1 : _current / max;
|
||
|
|
||
|
@override
|
||
|
String toString() => _$toString();
|
||
|
|
||
|
final int max;
|
||
|
final double step;
|
||
|
var _current = 0;
|
||
|
}
|
||
|
|
||
|
@ToString(ignoreNull: true)
|
||
|
class Progress {
|
||
|
const Progress(this.progress, [this.text]);
|
||
|
|
||
|
@override
|
||
|
String toString() => _$toString();
|
||
|
|
||
|
final double progress;
|
||
|
final String? text;
|
||
|
}
|