mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 12:04:50 +08:00
@@ -14,6 +14,13 @@ extension IterableExt<T> on Iterable<T> {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
T? firstWhereOrNull(bool Function(T element) test) {
|
||||
for (var element in this) {
|
||||
if (test(element)) return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
extension ListExt<T> on List<T> {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math' show pow;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
extension ImageExtension on num {
|
||||
@@ -13,3 +15,10 @@ extension IntExt on int? {
|
||||
int? operator +(int other) => this == null ? null : this! + other;
|
||||
int? operator -(int other) => this == null ? null : this! - other;
|
||||
}
|
||||
|
||||
extension DoubleExt on double {
|
||||
double toPrecision(int fractionDigits) {
|
||||
var mod = pow(10, fractionDigits.toDouble()).toDouble();
|
||||
return ((this * mod).round().toDouble() / mod);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user