Migrate to flutter 3.27.0

This commit is contained in:
2024-12-14 17:08:55 +08:00
parent 86c6f13282
commit bd15053c2f
23 changed files with 284 additions and 175 deletions

View File

@@ -183,21 +183,28 @@ class MyApp extends StatelessWidget {
}
}
/// from https://stackoverflow.com/a/60191441
int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
Color darken(Color c, [int percent = 10]) {
assert(1 <= percent && percent <= 100);
var f = 1 - percent / 100;
return Color.fromARGB(c.alpha, (c.red * f).round(), (c.green * f).round(),
(c.blue * f).round());
return Color.fromARGB(
_floatToInt8(c.a),
_floatToInt8(c.r * f),
_floatToInt8(c.g * f),
_floatToInt8(c.b * f),
);
}
/// from https://stackoverflow.com/a/60191441
Color lighten(Color c, [int percent = 10]) {
assert(1 <= percent && percent <= 100);
var p = percent / 100;
return Color.fromARGB(
c.alpha,
c.red + ((255 - c.red) * p).round(),
c.green + ((255 - c.green) * p).round(),
c.blue + ((255 - c.blue) * p).round());
_floatToInt8(c.a),
_floatToInt8(c.r + (1 - c.r) * p),
_floatToInt8(c.g + (1 - c.g) * p),
_floatToInt8(c.b + (1 - c.b) * p),
);
}