Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 79ca159

Browse files
Add day 58 example
1 parent 3523195 commit 79ca159

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

‎assets/screenshots/helicopter.png

345 KB
Loading[フレーム]

‎lib/pages/helicopter.dart

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import 'package:carousel_slider/carousel_slider.dart';
2+
import 'package:flutter/material.dart';
3+
4+
class HelicopterPage extends StatefulWidget {
5+
const HelicopterPage({ Key? key }) : super(key: key);
6+
7+
@override
8+
_HelicopterPageState createState() => _HelicopterPageState();
9+
}
10+
11+
class _HelicopterPageState extends State<HelicopterPage> {
12+
List<dynamic> _helicopters = [
13+
{
14+
'color': Color(0xff2DAAFA),
15+
'image': 'https://cdn.dribbble.com/users/4584084/screenshots/9271491/media/f32107904c73530191707403fa4fa6ea.gif',
16+
},
17+
{
18+
'color': Color(0xffE7CB91),
19+
'image': 'https://cdn.dribbble.com/users/721278/screenshots/6274521/helicopter_toy.gif',
20+
},
21+
{
22+
'color': Color(0xff731A01),
23+
'image': 'https://cdn.dribbble.com/users/210956/screenshots/3829094/media/3b6073f14271b5f7f809f34b468ae07c.gif',
24+
}
25+
];
26+
27+
int _current = 0;
28+
dynamic _selectedIndex = {};
29+
30+
CarouselController _carouselController = new CarouselController();
31+
32+
@override
33+
Widget build(BuildContext context) {
34+
return Scaffold(
35+
appBar: AppBar(
36+
elevation: 0,
37+
backgroundColor: Colors.white,
38+
title: Text('@theflutterlover', style: TextStyle(
39+
color: Colors.black,
40+
),),
41+
),
42+
body: Container(
43+
width: double.infinity,
44+
height: double.infinity,
45+
child: CarouselSlider(
46+
carouselController: _carouselController,
47+
options: CarouselOptions(
48+
height: 250.0,
49+
aspectRatio: 4/3,
50+
// viewportFraction: 0.70,
51+
// enlargeCenterPage: true,
52+
pageSnapping: true,
53+
onPageChanged: (index, reason) {
54+
setState(() {
55+
_current = index;
56+
});
57+
}
58+
),
59+
items: _helicopters.map((helicopter) {
60+
return Builder(
61+
builder: (BuildContext context) {
62+
return GestureDetector(
63+
onTap: () {
64+
// go to product view page with navigation push
65+
Navigator.of(context).push(
66+
MaterialPageRoute(
67+
builder: (context) => HelicopterView(
68+
helicopter: helicopter,
69+
),
70+
),
71+
);
72+
},
73+
child: AnimatedContainer(
74+
duration: Duration(milliseconds: 300),
75+
width: MediaQuery.of(context).size.width,
76+
margin: EdgeInsets.symmetric(horizontal: 10.0),
77+
decoration: BoxDecoration(
78+
color: Colors.white,
79+
borderRadius: BorderRadius.circular(20),
80+
boxShadow: [
81+
BoxShadow(
82+
color: Colors.grey.withOpacity(0.2),
83+
blurRadius: 20,
84+
offset: Offset(0, 5)
85+
)
86+
]
87+
),
88+
child: SingleChildScrollView(
89+
child: Column(
90+
children: [
91+
Hero(
92+
transitionOnUserGestures: true,
93+
tag: helicopter['color'],
94+
child: Container(
95+
height: 250,
96+
// margin: EdgeInsets.only(top: 15),
97+
clipBehavior: Clip.hardEdge,
98+
decoration: BoxDecoration(
99+
borderRadius: BorderRadius.circular(20),
100+
),
101+
child: Image.network(helicopter['image'], fit: BoxFit.cover),
102+
),
103+
),
104+
],
105+
),
106+
),
107+
),
108+
);
109+
},
110+
);
111+
}).toList()
112+
),
113+
),
114+
);
115+
}
116+
}
117+
118+
class HelicopterView extends StatefulWidget {
119+
final dynamic helicopter;
120+
const HelicopterView({ Key? key, required this.helicopter }) : super(key: key);
121+
122+
@override
123+
_HelicopterViewState createState() => _HelicopterViewState();
124+
}
125+
126+
class _HelicopterViewState extends State<HelicopterView> {
127+
@override
128+
Widget build(BuildContext context) {
129+
return Container(
130+
color: widget.helicopter['color'],
131+
child: Hero(
132+
tag: widget.helicopter['color'],
133+
transitionOnUserGestures: true,
134+
child: Image.network(widget.helicopter['image'])),
135+
);
136+
}
137+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /