Skip to content

Commit 4d754b7

Browse files
committed
Change toast to snackbar
1 parent b7c274b commit 4d754b7

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

lib/main.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class MyHomePage extends StatefulWidget {
4444

4545
class _MyHomePageState extends State<MyHomePage> {
4646

47+
@override
48+
void dispose() {
49+
widget.bloc.dispose();
50+
super.dispose();
51+
}
52+
4753
@override
4854
Widget build(BuildContext context) {
4955
return Scaffold(
@@ -106,7 +112,7 @@ class _MyHomePageState extends State<MyHomePage> {
106112
child: ListView.builder(
107113
itemCount: posts.length,
108114
itemBuilder: (BuildContext context, int index) {
109-
return _buildItem(posts[index]);
115+
return _buildItem(context, posts[index]);
110116
},
111117
),
112118
);
@@ -142,9 +148,9 @@ class _MyHomePageState extends State<MyHomePage> {
142148
);
143149
}
144150

145-
Widget _buildItem(Post post) {
151+
Widget _buildItem(BuildContext context, Post post) {
146152
return Padding(
147-
key: Key(post.description),
153+
key: Key(post.hash),
148154
padding: const EdgeInsets.all(16.0),
149155
child: ListTile(
150156
title: Padding(
@@ -161,13 +167,9 @@ class _MyHomePageState extends State<MyHomePage> {
161167
}
162168
},
163169
onLongPress: () {
164-
Fluttertoast.showToast(
165-
msg: "Not yet implemented.",
166-
toastLength: Toast.LENGTH_SHORT,
167-
gravity: ToastGravity.BOTTOM,
168-
timeInSecForIos: 1,
169-
);
170-
throw UnimplementedError;
170+
Scaffold.of(context).showSnackBar(SnackBar(
171+
content: Text('Not yet implementd'),
172+
));
171173
}
172174
),
173175
);

lib/src/pinyo_bloc.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class PinyoBloc {
111111
dispose() {
112112
// called when widget is removed from tree
113113
// here we close all our streams
114+
// this actually gets called from the widget
114115
_currentTagController.close();
115116
_isLoadingSubject.close();
116117
_postsSubject.close();

pubspec.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,6 @@ packages:
188188
description: flutter
189189
source: sdk
190190
version: "0.0.0"
191-
fluttertoast:
192-
dependency: "direct main"
193-
description:
194-
name: fluttertoast
195-
url: "https://pub.dartlang.org"
196-
source: hosted
197-
version: "2.2.3"
198191
front_end:
199192
dependency: transitive
200193
description:

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ environment:
1313
sdk: ">=2.0.0-dev.68.0 <3.0.0"
1414

1515
dependencies:
16-
fluttertoast: ^2.2.3
1716
rxdart: ^0.18.1
1817
http: ^0.12.0
1918
url_launcher: "^4.0.3"

0 commit comments

Comments
 (0)