-
Notifications
You must be signed in to change notification settings - Fork 2
/
_example_18.dart
71 lines (65 loc) · 1.99 KB
/
_example_18.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
// Declare a set list of images to cycle through as a final
final List<Image> _itemImages = [
Image.asset('assets/Google.png'),
Image.asset('assets/dtw.png'),
Image.asset('assets/GDGDetroit.png')
];
int _index = 0;
List<Image> _listOfImagesForScreen = [];
void onButtonPressed() {
setState(() {
_index++;
if (_index >= _itemImages.length) {
_index = 0;
}
_listOfImagesForScreen.add(_itemImages[_index]);
// print('Item Name = ' + _listOfImagesForScreen.toString());
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Detroit Tech Watch',
home: Scaffold(
appBar: AppBar(
title: Text('Detroit Tech Watch'),
),
body: Stack(
children: <Widget>[
ListView(
children: _listOfImagesForScreen
.map((element) => Card(
margin: EdgeInsets.all(8),
child: Column(
children: <Widget>[
element,
Padding(
padding: const EdgeInsets.all(8),
),
],
),
))
.toList(),
),
Positioned(
bottom: 16.0,
right: 16.0,
child: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
onButtonPressed();
},
))
],
)));
}
}