nc-photos/app/lib/progress_util.dart
2022-12-04 12:06:40 +08:00

34 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;
}