@@ -59,7 +59,7 @@ class _LayoutPageState extends State<LayoutPage> {
59
59
@override
60
60
Widget build (BuildContext context) {
61
61
if (isInitState) {
62
- SchedulerBinding .instance? .addPostFrameCallback ((_) {
62
+ SchedulerBinding .instance.addPostFrameCallback ((_) {
63
63
isInitState = false ;
64
64
});
65
65
}
@@ -240,7 +240,8 @@ class _LayoutPageState extends State<LayoutPage> {
240
240
'images/git_hub_mobile.png' ,
241
241
color: Colors .white),
242
242
onPressed: () {
243
- launch (currentSample! .codeLink! );
243
+ launchUrl (Uri .parse (
244
+ currentSample! .codeLink! ));
244
245
},
245
246
),
246
247
),
@@ -326,36 +327,36 @@ class _LayoutPageState extends State<LayoutPage> {
326
327
327
328
/// Get tabs which length is equal to list length
328
329
List <Widget > _getTabs (List <SubItem > list, [String ? tabView]) {
329
- final List <Widget > _tabs = < Widget > [];
330
- String _status ;
330
+ final List <Widget > tabs = < Widget > [];
331
+ String status ;
331
332
for (int i = 0 ; i < list.length; i++ ) {
332
333
if (list.isNotEmpty) {
333
- _status = getStatusTag (list[i]);
334
- _tabs .add (Tab (
334
+ status = getStatusTag (list[i]);
335
+ tabs .add (Tab (
335
336
child: Row (
336
337
children: < Widget > [
337
- Text (list[i].title.toString () + (_status != '' ? ' ' : '' ),
338
+ Text (list[i].title.toString () + (status != '' ? ' ' : '' ),
338
339
style: tabView != 'parent'
339
340
? const TextStyle (
340
341
fontSize: 14 , fontWeight: FontWeight .normal)
341
342
: const TextStyle (fontSize: 15 , color: Colors .white)),
342
- if (_status == '' )
343
+ if (status == '' )
343
344
Container ()
344
345
else
345
346
Container (
346
347
height: tabView != 'parent' ? 17 : 20 ,
347
348
width: tabView != 'parent' ? 17 : 20 ,
348
349
decoration: BoxDecoration (
349
- color: _status == 'N'
350
+ color: status == 'N'
350
351
? const Color .fromRGBO (55 , 153 , 30 , 1 )
351
- : _status == 'U'
352
+ : status == 'U'
352
353
? const Color .fromRGBO (246 , 117 , 0 , 1 )
353
354
: Colors .transparent,
354
355
shape: BoxShape .circle,
355
356
),
356
357
alignment: Alignment .center,
357
358
child: Text (
358
- _status ,
359
+ status ,
359
360
style: TextStyle (
360
361
fontSize: tabView != 'parent' ? 11 : 12 ,
361
362
color: Colors .white),
@@ -365,32 +366,32 @@ class _LayoutPageState extends State<LayoutPage> {
365
366
)));
366
367
}
367
368
}
368
- return _tabs ;
369
+ return tabs ;
369
370
}
370
371
371
372
/// To displaying sample in full screen height,
372
373
/// it doesn't contains expanded view.
373
374
List <Widget > _getFullViewSamples (SampleModel model, List <SubItem > list) {
374
- final List <Widget > _tabs = < Widget > [];
375
- SubItem _sampleDetail ;
376
- bool _needsFloatingBotton ;
375
+ final List <Widget > tabs = < Widget > [];
376
+ SubItem sampleDetail ;
377
+ bool needsFloatingBotton ;
377
378
for (int j = 0 ; j < list.length; j++ ) {
378
- _sampleDetail = list[j];
379
- _needsFloatingBotton = (_sampleDetail.sourceLink != null &&
380
- _sampleDetail .sourceLink != '' ) ||
381
- _sampleDetail .needsPropertyPanel == true ;
382
- final Function ? _sampleWidget = model.sampleWidget[list[j].key];
383
- final SampleView _sampleView =
384
- _sampleWidget !(GlobalKey <State >()) as SampleView ;
379
+ sampleDetail = list[j];
380
+ needsFloatingBotton =
381
+ (sampleDetail.sourceLink != null && sampleDetail .sourceLink != '' ) ||
382
+ (sampleDetail .needsPropertyPanel ?? false ) ;
383
+ final Function ? sampleWidget = model.sampleWidget[list[j].key];
384
+ final SampleView sampleView =
385
+ sampleWidget !(GlobalKey <State >()) as SampleView ;
385
386
386
- _tabs .add (
387
+ tabs .add (
387
388
Scaffold (
388
389
backgroundColor: model.cardThemeColor,
389
- body: _sampleView ,
390
- floatingActionButton: _needsFloatingBotton
390
+ body: sampleView ,
391
+ floatingActionButton: needsFloatingBotton
391
392
? Stack (children: < Widget > [
392
- if (_sampleDetail .sourceLink != null &&
393
- _sampleDetail .sourceLink != '' )
393
+ if (sampleDetail .sourceLink != null &&
394
+ sampleDetail .sourceLink != '' )
394
395
Align (
395
396
alignment: Alignment .bottomLeft,
396
397
child: Container (
@@ -399,13 +400,14 @@ class _LayoutPageState extends State<LayoutPage> {
399
400
height: 30 ,
400
401
width: 230 ,
401
402
child: InkWell (
402
- onTap: () => launch (_sampleDetail.sourceLink! ),
403
+ onTap: () =>
404
+ launchUrl (Uri .parse (sampleDetail.sourceLink! )),
403
405
child: Row (
404
406
children: < Widget > [
405
407
Text ('Source: ' ,
406
408
style: TextStyle (
407
409
fontSize: 16 , color: model.textColor)),
408
- Text (_sampleDetail .sourceText! ,
410
+ Text (sampleDetail .sourceText! ,
409
411
style: const TextStyle (
410
412
fontSize: 14 , color: Colors .blue)),
411
413
],
@@ -416,20 +418,20 @@ class _LayoutPageState extends State<LayoutPage> {
416
418
)
417
419
else
418
420
Container (),
419
- if (_sampleDetail .needsPropertyPanel != true )
421
+ if (sampleDetail .needsPropertyPanel != true )
420
422
Container ()
421
423
else
422
424
Align (
423
425
alignment: Alignment .bottomRight,
424
426
child: FloatingActionButton (
425
427
heroTag: null ,
426
428
onPressed: () {
427
- final GlobalKey _sampleKey =
428
- _sampleView .key! as GlobalKey ;
429
- final Widget _settingsContent =
430
- _getSettingsView (_sampleKey )! ;
429
+ final GlobalKey sampleKey =
430
+ sampleView .key! as GlobalKey ;
431
+ final Widget settingsContent =
432
+ _getSettingsView (sampleKey )! ;
431
433
showBottomSheetSettingsPanel (
432
- context, _settingsContent );
434
+ context, settingsContent );
433
435
},
434
436
backgroundColor: model.paletteColor,
435
437
child:
@@ -442,7 +444,7 @@ class _LayoutPageState extends State<LayoutPage> {
442
444
);
443
445
}
444
446
445
- return _tabs ;
447
+ return tabs ;
446
448
}
447
449
448
450
Widget ? _getSettingsView (GlobalKey sampleKey) {
@@ -453,7 +455,7 @@ class _LayoutPageState extends State<LayoutPage> {
453
455
final bool isDirectionalitySample =
454
456
sampleKey.currentState! is DirectionalitySampleViewState ;
455
457
if (isLocalizationSample || isDirectionalitySample) {
456
- return ListView (children: < Widget > [
458
+ return ListView (shrinkWrap : true , children: < Widget > [
457
459
(sampleKey.currentState! as LocalizationSampleViewState )
458
460
.localizationSelectorWidget (context),
459
461
if (isDirectionalitySample)
@@ -462,26 +464,25 @@ class _LayoutPageState extends State<LayoutPage> {
462
464
else
463
465
Container (),
464
466
sampleState.buildSettings (context) ?? Container ()
465
- ], shrinkWrap : true );
467
+ ]);
466
468
} else {
467
469
return sampleState.buildSettings (context);
468
470
}
469
471
}
470
472
471
473
/// To displaying sample in cards, it contains expanded sample view option.
472
474
List <Widget > _getCardViewSamples (SampleModel model, List <SubItem > list) {
473
- final List <Widget > _tabChildren = < Widget > [];
474
- Function _sampleWidget ;
475
- SampleView _sampleView ;
475
+ final List <Widget > tabChildren = < Widget > [];
476
+ Function sampleWidget ;
477
+ SampleView sampleView ;
476
478
for (int i = 0 ; i < list.length; i++ ) {
477
- _tabChildren .add (ListView .builder (
479
+ tabChildren .add (ListView .builder (
478
480
cacheExtent: (list.length).toDouble (),
479
- addAutomaticKeepAlives: true ,
480
481
itemCount: list.length,
481
482
itemBuilder: (BuildContext context, int position) {
482
- final String ? _status = list[position].status;
483
- _sampleWidget = model.sampleWidget[list[position].key]! ;
484
- _sampleView = _sampleWidget (GlobalKey <State >()) as SampleView ;
483
+ final String ? status = list[position].status;
484
+ sampleWidget = model.sampleWidget[list[position].key]! ;
485
+ sampleView = sampleWidget (GlobalKey <State >()) as SampleView ;
485
486
486
487
return Container (
487
488
color: model.themeData.colorScheme.brightness == Brightness .dark
@@ -528,25 +529,24 @@ class _LayoutPageState extends State<LayoutPage> {
528
529
children: < Widget > [
529
530
Container (
530
531
decoration: BoxDecoration (
531
- color: (_status != null && _status != '' )
532
- ? (_status == 'New' ||
533
- _status == 'new'
532
+ color: (status != null && status != '' )
533
+ ? (status == 'New' ||
534
+ status == 'new'
534
535
? const Color .fromRGBO (
535
536
55 , 153 , 30 , 1 )
536
537
: const Color .fromRGBO (
537
538
246 , 117 , 0 , 1 ))
538
539
: Colors .transparent,
539
- shape: BoxShape .rectangle,
540
540
borderRadius: const BorderRadius .all (
541
541
Radius .circular (10.0 ))),
542
542
padding: const EdgeInsets .fromLTRB (
543
543
5 , 2.7 , 5 , 2.7 ),
544
544
child: Text (
545
- (_status == 'New' ||
546
- _status == 'new' )
545
+ (status == 'New' ||
546
+ status == 'new' )
547
547
? 'New'
548
- : (_status == 'Updated' ||
549
- _status == 'updated' )
548
+ : (status == 'Updated' ||
549
+ status == 'updated' )
550
550
? 'Updated'
551
551
: '' ,
552
552
style: const TextStyle (fontSize: 12 , color: Colors .white))),
@@ -578,7 +578,7 @@ class _LayoutPageState extends State<LayoutPage> {
578
578
child: SizedBox (
579
579
width: double .infinity,
580
580
height: 230 ,
581
- child: _sampleView ),
581
+ child: sampleView ),
582
582
),
583
583
],
584
584
),
@@ -589,15 +589,15 @@ class _LayoutPageState extends State<LayoutPage> {
589
589
}));
590
590
}
591
591
592
- return _tabChildren ;
592
+ return tabChildren ;
593
593
}
594
594
595
595
/// If child type given to control subitems.
596
596
List <Widget > _getChildTabViewChildren (SampleModel model, List <SubItem > list) {
597
- final List <Widget > _tabs = < Widget > [];
597
+ final List <Widget > tabs = < Widget > [];
598
598
for (int i = 0 ; i < list.length; i++ ) {
599
599
if (list[i].subItems! .isNotEmpty) {
600
- _tabs .add (Container (
600
+ tabs .add (Container (
601
601
alignment: Alignment .center,
602
602
child: DefaultTabController (
603
603
length: list[i].subItems! .length,
@@ -641,16 +641,16 @@ class _LayoutPageState extends State<LayoutPage> {
641
641
));
642
642
}
643
643
}
644
- return _tabs ;
644
+ return tabs ;
645
645
}
646
646
647
647
/// If parent type given to control's subitem.
648
648
List <Widget > _getParentTabViewChildren (
649
649
SampleModel model, List <SubItem > list) {
650
- final List <Widget > _tabs = < Widget > [];
650
+ final List <Widget > tabs = < Widget > [];
651
651
for (int i = 0 ; i < list.length; i++ ) {
652
652
if (list[i].subItems! .isNotEmpty) {
653
- _tabs .add (Container (
653
+ tabs .add (Container (
654
654
alignment: Alignment .center,
655
655
child: DefaultTabController (
656
656
length: list[i].subItems! .length,
@@ -710,7 +710,7 @@ class _LayoutPageState extends State<LayoutPage> {
710
710
}
711
711
}
712
712
713
- return _tabs ;
713
+ return tabs ;
714
714
}
715
715
716
716
@override
0 commit comments