Skip to content

Commit 751911e

Browse files
author
Gordon Hayes
committed
refactor: analysis
1 parent 878cded commit 751911e

15 files changed

+164
-137
lines changed

section_6/routes_and_the_rest/lib/main.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_villains/villains/villains.dart';
3-
import 'package:routes_and_the_rest/ux/transitions/fade_transition_builder.dart';
43

54
import 'ux/pages/home.dart';
65
// import 'ux/transitions/fade_transition_builder.dart';
76

8-
void main() => runApp(MyApp());
7+
void main() => runApp(const MyApp());
98

109
class MyApp extends StatefulWidget {
10+
const MyApp({Key key}) : super(key: key);
11+
1112
@override
1213
_MyAppState createState() => _MyAppState();
1314
}
@@ -37,7 +38,7 @@ class _MyAppState extends State<MyApp> {
3738
},
3839
),
3940
),
40-
home: Home(),
41+
home: const Home(),
4142
);
4243
}
4344
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
class ContentModel {
2+
const ContentModel({
3+
this.title,
4+
this.description,
5+
this.logoLocation,
6+
this.logoTag,
7+
this.titleTag,
8+
});
9+
210
final String title;
311
final String description;
412
final String logoLocation;
513
final String logoTag;
614
final String titleTag;
7-
8-
ContentModel(this.title, this.description, this.logoLocation, this.logoTag, this.titleTag);
9-
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
import '../models/content_model.dart';
22

33
List<ContentModel> content = [
4-
ContentModel(
5-
'Flutter',
6-
'Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. Fun fact - this app is made in Flutter :)',
7-
'assets/images/flutter.png',
8-
'flutterLogoTag',
9-
'flutterTitleTag',
4+
const ContentModel(
5+
title: 'Flutter',
6+
description:
7+
'''Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. Fun fact - this app is made in Flutter :)''',
8+
logoLocation: 'assets/images/flutter.png',
9+
logoTag: 'flutterLogoTag',
10+
titleTag: 'flutterTitleTag',
1011
),
11-
ContentModel(
12-
'Angular',
13-
'Angular is a TypeScript-based open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations. Angular is a complete rewrite from the same team that built AngularJS.',
14-
'assets/images/angular.png',
15-
'angularLogoTag',
16-
'angularTitleTag',
12+
const ContentModel(
13+
title: 'Angular',
14+
description:
15+
'''Angular is a TypeScript-based open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations. Angular is a complete rewrite from the same team that built AngularJS.''',
16+
logoLocation: 'assets/images/angular.png',
17+
logoTag: 'angularLogoTag',
18+
titleTag: 'angularTitleTag',
1719
),
18-
ContentModel(
19-
'React',
20-
'React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications.',
21-
'assets/images/react.png',
22-
'reactLogoTag',
23-
'reactTitleTag',
20+
const ContentModel(
21+
title: 'React',
22+
description:
23+
'''React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications.''',
24+
logoLocation: 'assets/images/react.png',
25+
logoTag: 'reactLogoTag',
26+
titleTag: 'reactTitleTag',
2427
),
25-
ContentModel(
26-
'Vue',
27-
'Vue.js is an open-source Model–view–viewmodel JavaScript framework for building user interfaces and single-page applications. It was created by Evan You, and is maintained by him and the rest of the active core team members coming from various companies such as Netlify and Netguru.',
28-
'assets/images/vue.png',
29-
'vueLogoTag',
30-
'vueTitleTag',
28+
const ContentModel(
29+
title: 'Vue',
30+
description:
31+
'''Vue.js is an open-source Model–view–viewmodel JavaScript framework for building user interfaces and single-page applications. It was created by Evan You, and is maintained by him and the rest of the active core team members coming from various companies such as Netlify and Netguru.''',
32+
logoLocation: 'assets/images/vue.png',
33+
logoTag: 'vueLogoTag',
34+
titleTag: 'vueTitleTag',
3135
),
32-
ContentModel(
33-
'Swift',
34-
"Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, iPadOS, macOS, watchOS, tvOS, Linux, and z/OS. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products.",
35-
'assets/images/swift.png',
36-
'swiftLogoTag',
37-
'swiftTitleTag',
36+
const ContentModel(
37+
title: 'Swift',
38+
description:
39+
'''Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, iPadOS, macOS, watchOS, tvOS, Linux, and z/OS. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products.''',
40+
logoLocation: 'assets/images/swift.png',
41+
logoTag: 'swiftLogoTag',
42+
titleTag: 'swiftTitleTag',
3843
)
3944
];

section_6/routes_and_the_rest/lib/ux/extensions/bounce_extensions.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ extension BounceExtension on Widget {
99
}
1010

1111
class _BounceOutAnimation extends StatefulWidget {
12-
_BounceOutAnimation({Key key, this.child}) : super(key: key);
12+
const _BounceOutAnimation({Key key, this.child}) : super(key: key);
13+
1314
final Widget child;
1415

1516
@override
@@ -40,7 +41,7 @@ class _BounceOutAnimationState extends State<_BounceOutAnimation>
4041
@override
4142
void initState() {
4243
_controller =
43-
AnimationController(vsync: this, duration: Duration(seconds: 2));
44+
AnimationController(vsync: this, duration: const Duration(seconds: 2));
4445
_animation = _offsetTween.animate(_controller);
4546

4647
_controller.repeat();

section_6/routes_and_the_rest/lib/ux/pages/home.dart

+9-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import '../widgets/zoom_page_view.dart';
1212
import 'learn_more_page.dart';
1313

1414
class Home extends StatefulWidget {
15-
Home({Key key}) : super(key: key);
15+
const Home({Key key}) : super(key: key);
1616

1717
@override
1818
_HomeState createState() => _HomeState();
@@ -53,24 +53,24 @@ class _HomeState extends State<Home>
5353
@override
5454
void didChangeDependencies() {
5555
super.didChangeDependencies();
56-
routeObserver.subscribe(this, ModalRoute.of(context));
56+
routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
5757
}
5858

5959
@override
6060
void didPush() {
61-
print('push');
61+
debugPrint('push');
6262
super.didPush();
6363
}
6464

6565
@override
6666
void didPushNext() {
67-
print('push next');
67+
debugPrint('push next');
6868
super.didPushNext();
6969
}
7070

7171
@override
7272
void didPopNext() {
73-
print('pop next');
73+
debugPrint('pop next');
7474
if (!(_controller.value > 0)) {
7575
return;
7676
}
@@ -82,7 +82,7 @@ class _HomeState extends State<Home>
8282

8383
@override
8484
void didPop() {
85-
print('pop');
85+
debugPrint('pop');
8686
super.didPop();
8787
}
8888

@@ -91,11 +91,11 @@ class _HomeState extends State<Home>
9191
}
9292

9393
void _transitionRoute() {
94-
Navigator.of(context).push(_createRoute());
94+
Navigator.of(context).push<dynamic>(_createRoute());
9595
}
9696

9797
Route _createRoute() {
98-
return PageRouteBuilder(
98+
return PageRouteBuilder<dynamic>(
9999
transitionDuration: _transitionDuration,
100100
pageBuilder: (context, animation, secondaryAnimation) =>
101101
const LearnMorePage(),
@@ -120,20 +120,13 @@ class _HomeState extends State<Home>
120120
children: <Widget>[
121121
ValueListenableBuilder(
122122
valueListenable: _valueNotifier,
123-
builder: (context, value, child) {
123+
builder: (BuildContext context, double value, Widget child) {
124124
return BinarayBackround(value: _valueNotifier.value);
125125
},
126126
),
127127
Column(
128128
mainAxisAlignment: MainAxisAlignment.spaceAround,
129129
children: <Widget>[
130-
// Padding(
131-
// padding: const EdgeInsets.all(16.0),
132-
// child: Text(
133-
// 'Front-end Frameworks',
134-
// style: Theme.of(context).textTheme.display1,
135-
// ),
136-
// ),
137130
ZoomPageScroll(
138131
pageController: _pageController,
139132
value: _valueNotifier,

section_6/routes_and_the_rest/lib/ux/pages/info_page.dart

+12-7
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@ import '../../models/content_model.dart';
66
import '../styles/styles.dart';
77

88
class InfoPage extends StatelessWidget {
9-
final ContentModel content;
10-
11-
InfoPage({
9+
const InfoPage({
1210
Key key,
1311
@required this.content,
1412
}) : super(key: key);
1513

14+
final ContentModel content;
15+
1616
@override
1717
Widget build(BuildContext context) {
1818
return Scaffold(
19+
extendBodyBehindAppBar: true,
20+
appBar: AppBar(
21+
backgroundColor: Colors.transparent,
22+
elevation: 0,
23+
),
1924
body: Stack(
2025
children: <Widget>[
2126
Container(color: greyBlueColor),
2227
Align(
2328
alignment: Alignment.bottomCenter,
2429
child: Villain(
2530
villainAnimation: VillainAnimation.fromBottom(
26-
from: Duration(milliseconds: 300),
27-
to: Duration(milliseconds: 600),
31+
from: const Duration(milliseconds: 300),
32+
to: const Duration(milliseconds: 600),
2833
),
2934
child: FractionallySizedBox(
3035
heightFactor: 0.75,
@@ -33,7 +38,7 @@ class InfoPage extends StatelessWidget {
3338
child: Container(
3439
decoration: BoxDecoration(
3540
color: gummentalColor,
36-
boxShadow: [
41+
boxShadow: const [
3742
BoxShadow(
3843
color: Colors.black87,
3944
blurRadius: 10,
@@ -60,7 +65,7 @@ class InfoPage extends StatelessWidget {
6065
),
6166
),
6267
Align(
63-
alignment: Alignment(0, -0.8),
68+
alignment: const Alignment(0, -0.8),
6469
child: FractionallySizedBox(
6570
heightFactor: 0.3,
6671
child: Hero(

0 commit comments

Comments
 (0)