aves_mio1/lib/widgets/common/fx/borders.dart
FabioMich66 19a982ede6
Some checks are pending
Quality check / Flutter analysis (push) Waiting to run
Quality check / CodeQL analysis (java-kotlin) (push) Waiting to run
first commit
2026-03-05 15:51:30 +01:00

24 lines
1,021 B
Dart

import 'package:aves/widgets/common/extensions/theme.dart';
import 'package:flutter/material.dart';
class AvesBorder {
static Color _borderColor(BuildContext context) => Theme.of(context).isDark ? Colors.white30 : Colors.black26;
// 1 device pixel for straight lines is fine
static double straightBorderWidth(BuildContext context) => 1 / MediaQuery.devicePixelRatioOf(context);
// 1 device pixel for curves is too thin
static double curvedBorderWidth(BuildContext context) => MediaQuery.devicePixelRatioOf(context) > 2 ? 0.5 : 1.0;
static BorderSide straightSide(BuildContext context, {double? width}) => BorderSide(
color: _borderColor(context),
width: width ?? straightBorderWidth(context),
);
static BorderSide curvedSide(BuildContext context, {double? width}) => BorderSide(
color: _borderColor(context),
width: width ?? curvedBorderWidth(context),
);
static Border border(BuildContext context, {double? width}) => Border.fromBorderSide(curvedSide(context, width: width));
}