Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/src/units/energy_density/energy_density_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ enum EnergyDensityUnit implements LinearUnit<EnergyDensityUnit> {
@override
final String symbol;

/// Returns `true` only for [joulePerCubicMeter], the SI derived unit of energy density.
@override
bool get isSI => this == EnergyDensityUnit.joulePerCubicMeter;

/// Returns `true` for all units, since every `EnergyDensityUnit` member is
/// a decimal metric unit.
@override
bool get isMetric => true;

// --- Pre-calculated direct conversion factors ---
final double _factorToJoulePerCubicMeter;
final double _factorToJoulePerLiter;
Expand Down
16 changes: 16 additions & 0 deletions lib/src/units/volumetric_flow_rate/volumetric_flow_rate_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ enum VolumetricFlowRateUnit implements LinearUnit<VolumetricFlowRateUnit> {
@override
final String symbol;

/// Returns `true` only for [cubicMeterPerSecond], the SI derived unit of volumetric flow rate.
@override
bool get isSI => this == VolumetricFlowRateUnit.cubicMeterPerSecond;

/// Returns `false` for the imperial/US customary [cubicFootPerSecond],
/// [cubicFootPerMinute], [gallonPerMinute], and [gallonPerHour]; `true`
/// for all decimal metric cubic-meter- and liter-based units.
@override
bool get isMetric => switch (this) {
VolumetricFlowRateUnit.cubicFootPerSecond ||
VolumetricFlowRateUnit.cubicFootPerMinute ||
VolumetricFlowRateUnit.gallonPerMinute ||
VolumetricFlowRateUnit.gallonPerHour => false,
_ => true,
};

// --- Pre-calculated direct conversion factors from this unit to all others ---
final double _factorToCubicMeterPerSecond;
final double _factorToCubicMeterPerMinute;
Expand Down
Loading