BankLiveExchangeConverter class
Two-sided live currency converter.
Editing the FROM field recomputes the TO field automatically, and vice versa. A swap button flips the direction. The "Convert" button is enabled only when the entered amount is positive and calls onConvert.
The host app is responsible for supplying a fresh ExchangeRate whenever the rate changes; the widget is stateless with respect to rate data.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BankLiveExchangeConverter
Constructors
-
BankLiveExchangeConverter({required ExchangeRate rate, Key? key, VoidCallback? onConvert, ValueChanged<
Money> ? onAmountChanged, EdgeInsetsGeometry? padding, String hintText = '0.00', IconData swapIcon = Icons.swap_vert, String swapSemanticLabel = 'Swap currencies', String convertSemanticLabel = 'Convert', String rateTemplate = '1 {from} = {rate} {to}', String rateSeparator = ' • ', String updatedJustNowLabel = 'updated just now', String updatedMinutesTemplate = 'updated {n}m ago', String updatedHoursTemplate = 'updated {n}h ago', BorderRadius? fieldRadius, Color? fieldFillColor, Color? swapButtonColor, Color? accentColor, BorderRadius? buttonRadius, TextStyle? fieldLabelStyle, TextStyle? inputStyle, TextStyle? hintStyle, TextStyle? rateLabelStyle, TextStyle? convertLabelStyle}) -
const
Properties
- accentColor → Color?
-
Overrides the primary accent (convert button background and the
focused-field border). Defaults to the theme primary.
final
-
Overrides the convert button corner radius. Defaults to the theme
buttonRadius.
final
- convertLabelStyle → TextStyle?
-
Merged over the convert button label style
(BankTokens.labelLarge in onPrimary).
final
- convertSemanticLabel → String
-
Semantic label for the convert button. Defaults to
'Convert'.final - fieldFillColor → Color?
-
Overrides the amount-field fill colour. Defaults to the theme
surfaceVariant.
final
- fieldLabelStyle → TextStyle?
-
Merged over the field-label style
(BankTokens.labelMedium in onSurfaceVariant).
final
- fieldRadius → BorderRadius?
-
Overrides the amount-field corner radius. Defaults to
BorderRadius.circular(BankTokens.radiusMedium).final - hashCode → int
-
The hash code for this object.
no setterinherited
- hintStyle → TextStyle?
-
Merged over the amount-input hint style
(numeralSmall in onSurfaceVariant).
final
- hintText → String
-
Placeholder shown in each empty amount field. Defaults to
'0.00'.final - inputStyle → TextStyle?
-
Merged over the amount-input text style (numeralSmall in onSurface).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onAmountChanged
→ ValueChanged<
Money> ? -
Called whenever the FROM amount changes, with the computed Money value.
final
- onConvert → VoidCallback?
-
Called when the user taps the "Convert" button.
final
- padding → EdgeInsetsGeometry?
-
Overrides the outer padding around the converter. Defaults to none.
final
- rate → ExchangeRate
-
The current exchange rate used for conversion.
final
- rateLabelStyle → TextStyle?
-
Merged over the rate line style (BankTokens.bodySmall in
onSurfaceVariant).
final
- rateSeparator → String
-
Separator between the rate line and the freshness line. Defaults to
' • '.final - rateTemplate → String
-
Rate line template.
{from},{rate}, and{to}are substituted. Defaults to'1 {from} = {rate} {to}'.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- swapButtonColor → Color?
-
Overrides the swap button background. Defaults to the theme
surfaceVariant.
final
- swapIcon → IconData
-
Glyph on the swap button. Defaults to Icons.swap_vert.
final
- swapSemanticLabel → String
-
Semantic label for the swap button. Defaults to
'Swap currencies'.final - updatedHoursTemplate → String
-
Freshness template in hours;
{n}is substituted. Defaults to'updated {n}h ago'.final - updatedJustNowLabel → String
-
Freshness label used within the last minute. Defaults to
'updated just now'.final - updatedMinutesTemplate → String
-
Freshness template in minutes;
{n}is substituted. Defaults to'updated {n}m ago'.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BankLiveExchangeConverter> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited