@@ -66,18 +66,16 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
6666 efCurrencyPairProvider.select ((value) => value.receive),
6767 );
6868 final reversed = ref.watch (efReversedProvider);
69- final amount =
70- reversed
71- ? ref.watch (efReceiveAmountProvider)
72- : ref.watch (efSendAmountProvider);
69+ final amount = reversed
70+ ? ref.watch (efReceiveAmountProvider)
71+ : ref.watch (efSendAmountProvider);
7372
7473 final data = ref.watch (efEstimatesListProvider (widget.exchange.name));
7574 final estimates = data? .item1.value;
7675
77- final pair =
78- sendCurrency != null && receivingCurrency != null
79- ? (from: sendCurrency, to: receivingCurrency)
80- : null ;
76+ final pair = sendCurrency != null && receivingCurrency != null
77+ ? (from: sendCurrency, to: receivingCurrency)
78+ : null ;
8179
8280 return AnimatedSize (
8381 duration: const Duration (milliseconds: 500 ),
@@ -86,7 +84,7 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
8684 builder: (_) {
8785 if (ref.watch (efRefreshingProvider)) {
8886 // show loading
89- return _ProviderOption (
87+ return ExchProviderOption (
9088 exchange: widget.exchange,
9189 estimate: null ,
9290 pair: pair,
@@ -108,10 +106,9 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
108106
109107 int decimals;
110108 try {
111- decimals =
112- AppConfig .getCryptoCurrencyForTicker (
113- receivingCurrency.ticker,
114- )! .fractionDigits;
109+ decimals = AppConfig .getCryptoCurrencyForTicker (
110+ receivingCurrency.ticker,
111+ )! .fractionDigits;
115112 } catch (_) {
116113 decimals = 8 ; // some reasonable alternative
117114 }
@@ -161,23 +158,21 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
161158
162159 return ConditionalParent (
163160 condition: i > 0 ,
164- builder:
165- (child) => Column (
166- mainAxisSize: MainAxisSize .min,
167- children: [
168- isDesktop
169- ? Container (
170- height: 1 ,
171- color:
172- Theme .of (context)
173- .extension < StackColors > ()!
174- .background,
175- )
176- : const SizedBox (height: 16 ),
177- child,
178- ],
179- ),
180- child: _ProviderOption (
161+ builder: (child) => Column (
162+ mainAxisSize: MainAxisSize .min,
163+ children: [
164+ isDesktop
165+ ? Container (
166+ height: 1 ,
167+ color: Theme .of (
168+ context,
169+ ).extension < StackColors > ()! .background,
170+ )
171+ : const SizedBox (height: 16 ),
172+ child,
173+ ],
174+ ),
175+ child: ExchProviderOption (
181176 key: Key (widget.exchange.name + e.exchangeProvider),
182177 exchange: widget.exchange,
183178 pair: pair,
@@ -209,26 +204,27 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
209204 } else if (data? .item1.value == null ) {
210205 final rateType =
211206 ref.watch (efRateTypeProvider) ==
212- ExchangeRateType .estimated
213- ? "estimated"
214- : "fixed" ;
207+ ExchangeRateType .estimated
208+ ? "estimated"
209+ : "fixed" ;
215210 message ?? = "Pair unavailable on $rateType rate flow" ;
216211 }
217212
218- return _ProviderOption (
213+ return ExchProviderOption (
219214 exchange: widget.exchange,
220215 estimate: null ,
221216 pair: pair,
222217 rateString: message ?? "Failed to fetch rate" ,
223- rateColor:
224- Theme .of (context).extension < StackColors > ()! .textError,
218+ rateColor: Theme .of (
219+ context,
220+ ).extension < StackColors > ()! .textError,
225221 );
226222 },
227223 );
228224 }
229225 } else {
230226 // show n/a
231- return _ProviderOption (
227+ return ExchProviderOption (
232228 exchange: widget.exchange,
233229 estimate: null ,
234230 pair: pair,
@@ -241,8 +237,8 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
241237 }
242238}
243239
244- class _ProviderOption extends ConsumerStatefulWidget {
245- const _ProviderOption ({
240+ class ExchProviderOption extends ConsumerStatefulWidget {
241+ const ExchProviderOption ({
246242 super .key,
247243 required this .exchange,
248244 required this .estimate,
@@ -262,10 +258,10 @@ class _ProviderOption extends ConsumerStatefulWidget {
262258 final Color ? rateColor;
263259
264260 @override
265- ConsumerState <_ProviderOption > createState () => _ProviderOptionState ();
261+ ConsumerState <ExchProviderOption > createState () => _ProviderOptionState ();
266262}
267263
268- class _ProviderOptionState extends ConsumerState <_ProviderOption > {
264+ class _ProviderOptionState extends ConsumerState <ExchProviderOption > {
269265 final isDesktop = Util .isDesktop;
270266
271267 late final String _id;
@@ -335,9 +331,8 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> {
335331
336332 return ConditionalParent (
337333 condition: isDesktop,
338- builder:
339- (child) =>
340- MouseRegion (cursor: SystemMouseCursors .click, child: child),
334+ builder: (child) =>
335+ MouseRegion (cursor: SystemMouseCursors .click, child: child),
341336 child: GestureDetector (
342337 onTap: () {
343338 ref.read (efExchangeProvider.notifier).state = widget.exchange;
@@ -347,8 +342,9 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> {
347342 child: Container (
348343 color: Colors .transparent,
349344 child: Padding (
350- padding:
351- isDesktop ? const EdgeInsets .all (16 ) : const EdgeInsets .all (0 ),
345+ padding: isDesktop
346+ ? const EdgeInsets .all (16 )
347+ : const EdgeInsets .all (0 ),
352348 child: Row (
353349 crossAxisAlignment: CrossAxisAlignment .start,
354350 children: [
@@ -358,18 +354,18 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> {
358354 child: Padding (
359355 padding: EdgeInsets .only (top: isDesktop ? 20.0 : 15.0 ),
360356 child: Radio (
361- activeColor:
362- Theme .of (
363- context,
364- ).extension < StackColors > ()! .radioButtonIconEnabled,
357+ activeColor: Theme .of (
358+ context,
359+ ).extension < StackColors > ()! .radioButtonIconEnabled,
365360 value: _id,
366361 groupValue: groupValue,
367362 onChanged: (_) {
368363 ref.read (efExchangeProvider.notifier).state =
369364 widget.exchange;
370365 ref
371- .read (efExchangeProviderNameProvider.notifier)
372- .state = widget.estimate? .exchangeProvider ??
366+ .read (efExchangeProviderNameProvider.notifier)
367+ .state =
368+ widget.estimate? .exchangeProvider ??
373369 widget.exchange.name;
374370 },
375371 ),
@@ -383,47 +379,41 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> {
383379 height: isDesktop ? 32 : 24 ,
384380 child:
385381 widget.estimate? .exchangeProviderLogo != null &&
386- widget
387- .estimate!
388- .exchangeProviderLogo!
389- .isNotEmpty
390- ? ClipRRect (
391- borderRadius: BorderRadius .circular (5 ),
392- child: Image .network (
393- widget.estimate! .exchangeProviderLogo! ,
394- loadingBuilder: (
395- context,
396- child,
397- loadingProgress,
398- ) {
399- if (loadingProgress == null ) {
400- return child;
401- } else {
402- return const Center (
403- child: CircularProgressIndicator (),
404- );
405- }
406- },
407- errorBuilder: (context, error, stackTrace) {
408- return SvgPicture .asset (
409- Assets .exchange.getIconFor (
410- exchangeName: widget.exchange.name,
411- ),
412- width: isDesktop ? 32 : 24 ,
413- height: isDesktop ? 32 : 24 ,
414- );
415- },
416- width: isDesktop ? 32 : 24 ,
417- height: isDesktop ? 32 : 24 ,
418- ),
419- )
420- : SvgPicture .asset (
421- Assets .exchange.getIconFor (
422- exchangeName: widget.exchange.name,
423- ),
382+ widget.estimate! .exchangeProviderLogo! .isNotEmpty
383+ ? ClipRRect (
384+ borderRadius: BorderRadius .circular (5 ),
385+ child: Image .network (
386+ widget.estimate! .exchangeProviderLogo! ,
387+ loadingBuilder:
388+ (context, child, loadingProgress) {
389+ if (loadingProgress == null ) {
390+ return child;
391+ } else {
392+ return const Center (
393+ child: CircularProgressIndicator (),
394+ );
395+ }
396+ },
397+ errorBuilder: (context, error, stackTrace) {
398+ return SvgPicture .asset (
399+ Assets .exchange.getIconFor (
400+ exchangeName: widget.exchange.name,
401+ ),
402+ width: isDesktop ? 32 : 24 ,
403+ height: isDesktop ? 32 : 24 ,
404+ );
405+ },
424406 width: isDesktop ? 32 : 24 ,
425407 height: isDesktop ? 32 : 24 ,
426408 ),
409+ )
410+ : SvgPicture .asset (
411+ Assets .exchange.getIconFor (
412+ exchangeName: widget.exchange.name,
413+ ),
414+ width: isDesktop ? 32 : 24 ,
415+ height: isDesktop ? 32 : 24 ,
416+ ),
427417 ),
428418 ),
429419 const SizedBox (width: 10 ),
@@ -435,55 +425,54 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> {
435425 children: [
436426 ConditionalParent (
437427 condition: _warnings.isNotEmpty,
438- builder:
439- (child) => Row (
440- mainAxisAlignment: MainAxisAlignment .spaceBetween,
441- children: [
442- child,
443- CustomTextButton (
444- text: _warnings.first.value,
445- onTap: () {
446- _showNoSparkWarning ();
447- },
448- ),
449- ],
428+ builder: (child) => Row (
429+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
430+ children: [
431+ child,
432+ CustomTextButton (
433+ text: _warnings.first.value,
434+ onTap: () {
435+ _showNoSparkWarning ();
436+ },
450437 ),
438+ ],
439+ ),
451440 child: Text (
452441 widget.estimate? .exchangeProvider ??
453442 widget.exchange.name,
454443 style: STextStyles .titleBold12 (context).copyWith (
455- color:
456- Theme .of (
457- context,
458- ).extension < StackColors > ()! .textDark2,
444+ color: Theme .of (
445+ context,
446+ ).extension < StackColors > ()! .textDark2,
459447 ),
460448 ),
461449 ),
462450 widget.loadingString
463451 ? AnimatedText (
464- stringsToLoopThrough: const [
465- "Loading" ,
466- "Loading." ,
467- "Loading.." ,
468- "Loading..." ,
469- ],
470- style: STextStyles .itemSubtitle12 (context). copyWith (
471- color :
472- Theme .of (
473- context,
474- ).extension < StackColors > ()! .textSubtitle1,
475- ),
476- )
452+ stringsToLoopThrough: const [
453+ "Loading" ,
454+ "Loading." ,
455+ "Loading.." ,
456+ "Loading..." ,
457+ ],
458+ style: STextStyles .itemSubtitle12 (context)
459+ . copyWith (
460+ color : Theme .of (
461+ context,
462+ ).extension < StackColors > ()! .textSubtitle1,
463+ ),
464+ )
477465 : Text (
478- widget.rateString,
479- style: STextStyles .itemSubtitle12 (context).copyWith (
480- color:
481- widget.rateColor ??
482- Theme .of (
483- context,
484- ).extension < StackColors > ()! .textSubtitle1,
466+ widget.rateString,
467+ style: STextStyles .itemSubtitle12 (context)
468+ .copyWith (
469+ color:
470+ widget.rateColor ??
471+ Theme .of (context)
472+ .extension < StackColors > ()!
473+ .textSubtitle1,
474+ ),
485475 ),
486- ),
487476 ],
488477 ),
489478 ),
0 commit comments