-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bhargav
committed
Jul 19, 2022
1 parent
a3d8add
commit 1a629d6
Showing
9 changed files
with
284 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
## 0.3.5 | ||
|
||
- Added quantities | ||
- `Volume` | ||
|
||
## 0.3.4 | ||
|
||
- Added quantities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import 'package:invertible/invertible.dart'; | ||
|
||
import 'base/base_quantity.dart'; | ||
import 'base/length.dart'; | ||
import 'quantity.dart'; | ||
import 'unit.dart'; | ||
|
||
/// Represents quantity Volume | ||
class Volume extends Quantity<Volume> { | ||
/// Constructs Volume with the value and the unit | ||
Volume(num value, String unitSymbol) | ||
: super(value, unitSymbol, _V._dimension); | ||
|
||
/// Constructs Volume with the value in SI unit | ||
const Volume.si(num siValue) : super.si(siValue, _V._dimension); | ||
} | ||
|
||
class _V extends Dimension<Volume> { | ||
factory _V() => _dimension; | ||
|
||
const _V._internal() | ||
: super( | ||
const <BaseDimension<dynamic>, num>{L.dimension: 3}, | ||
siUnitSymbol: 'm3', | ||
allUnits: const <String, Unit>{ | ||
'm3': Unit('cubic metre', toSI: <InvertibleRealFunction>[]), | ||
'kl': Unit('kilolitre', toSI: <InvertibleRealFunction>[]), | ||
'dm3': Unit( | ||
'cubic decimetre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'dm', | ||
}, | ||
), | ||
'l': Unit( | ||
'litre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'dm', | ||
}, | ||
), | ||
'cm3': Unit( | ||
'cubic centimetre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'cm', | ||
}, | ||
), | ||
'ml': Unit( | ||
'millilitre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'cm', | ||
}, | ||
), | ||
'mm3': Unit( | ||
'cubic millimetre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'mm', | ||
}, | ||
), | ||
'µl': Unit( | ||
'microlitre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'mm', | ||
}, | ||
), | ||
'dam3': Unit( | ||
'cubic decametre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'dam', | ||
}, | ||
), | ||
'Ml': Unit( | ||
'megalitre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'dam', | ||
}, | ||
), | ||
'hm3': Unit( | ||
'cubic hectometre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'hm', | ||
}, | ||
), | ||
'Gl': Unit( | ||
'gigalitre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'hm', | ||
}, | ||
), | ||
'km3': Unit( | ||
'cubic kilometre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'km', | ||
}, | ||
), | ||
'Tl': Unit( | ||
'teralitre', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'km', | ||
}, | ||
), | ||
'in3': Unit( | ||
'cubic inch', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'in', | ||
}, | ||
), | ||
'ft3': Unit( | ||
'cubic foot', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'ft', | ||
}, | ||
), | ||
'mi3': Unit( | ||
'cubic mile', | ||
baseUnitSymbols: <BaseDimension<dynamic>, String>{ | ||
L.dimension: 'mi', | ||
}, | ||
), | ||
'gal': Unit( | ||
'gallon', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(0.00454609), | ||
], | ||
), | ||
'qt': Unit( | ||
'quart', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(0.0011365225), | ||
], | ||
), | ||
'pt': Unit( | ||
'pint', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(5.6826125e-4), | ||
], | ||
), | ||
'fl-oz': Unit( | ||
'fluid ounce', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(2.84130625e-5), | ||
], | ||
), | ||
'tbsp': Unit( | ||
'tablespoon', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(1.5e-5), | ||
], | ||
), | ||
'tsp': Unit( | ||
'teaspoon', | ||
toSI: <InvertibleRealFunction>[ | ||
Multiplication(5e-6), | ||
], | ||
), | ||
}, | ||
); | ||
|
||
@override | ||
Volume si(num siValue) => Volume.si(siValue); | ||
|
||
static const _V _dimension = _V._internal(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:converter/converter.dart'; | ||
|
||
final Map<String, dynamic> volumeConverter = <String, dynamic>{ | ||
'testCases': <Map<String, dynamic>>[ | ||
<String, dynamic>{ | ||
'quantity': Volume.si(139), | ||
'siValue': 139, | ||
'valueIn': <String, num>{ | ||
'm3': 139, | ||
'kl': 139, | ||
'dm3': 1.39e5, | ||
'l': 1.39e5, | ||
'cm3': 1.39e8, | ||
'ml': 1.39e8, | ||
'mm3': 1.39e11, | ||
'µl': 1.39e11, | ||
'dam3': 0.139, | ||
'Ml': 0.139, | ||
'hm3': 1.39e-4, | ||
'Gl': 1.39e-4, | ||
'km3': 1.39e-7, | ||
'Tl': 1.39e-7, | ||
'in3': 8.4823e6, | ||
'ft3': 4908.74, | ||
'mi3': 3.33479e-8, | ||
'gal': 30575.7, | ||
'qt': 122303, | ||
'pt': 244606, | ||
'fl-oz': 4.892116e6, | ||
'tbsp': 9.266666e6, | ||
'tsp': 2.78e7, | ||
}, | ||
}, | ||
<String, dynamic>{ | ||
'quantity': Volume(149, 'µl'), | ||
'siValue': 1.49e-7, | ||
'valueIn': <String, num>{ | ||
'm3': 1.49e-7, | ||
'kl': 1.49e-7, | ||
'dm3': 1.49e-4, | ||
'l': 1.49e-4, | ||
'cm3': 0.149, | ||
'ml': 0.149, | ||
'mm3': 149, | ||
'µl': 149, | ||
'dam3': 1.49e-10, | ||
'Ml': 1.49e-10, | ||
'hm3': 1.49e-13, | ||
'Gl': 1.49e-13, | ||
'km3': 1.49e-16, | ||
'Tl': 1.49e-16, | ||
'in3': 0.009092537, | ||
'ft3': 5.261885e-6, | ||
'mi3': 3.5747e-17, | ||
'gal': 3.277541e-5, | ||
'qt': 1.311016e-4, | ||
'pt': 2.622032e-4, | ||
'fl-oz': 0.005244067, | ||
'tbsp': 0.009933333, | ||
'tsp': 0.0298, | ||
}, | ||
}, | ||
<String, dynamic>{ | ||
'quantity': Volume(151, 'Ml'), | ||
'siValue': 1.51e5, | ||
'valueIn': <String, num>{ | ||
'm3': 1.51e5, | ||
'kl': 1.51e5, | ||
'dm3': 1.51e8, | ||
'l': 1.51e8, | ||
'cm3': 1.51e11, | ||
'ml': 1.51e11, | ||
'mm3': 1.51e14, | ||
'µl': 1.51e14, | ||
'dam3': 151, | ||
'Ml': 151, | ||
'hm3': 0.151, | ||
'Gl': 0.151, | ||
'km3': 1.51e-4, | ||
'Tl': 1.51e-4, | ||
'in3': 9.214585e9, | ||
'ft3': 5.332514e6, | ||
'mi3': 3.622682e-5, | ||
'gal': 3.321535e7, | ||
'qt': 1.328614e8, | ||
'pt': 2.657228e8, | ||
'fl-oz': 5.314457e9, | ||
'tbsp': 1.006666e10, | ||
'tsp': 3.02e10, | ||
}, | ||
}, | ||
], | ||
}; |