-
Notifications
You must be signed in to change notification settings - Fork 19
/
day071_notification_listener.dart
90 lines (85 loc) · 3.1 KB
/
day071_notification_listener.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class Day71NotificationListener extends StatefulWidget {
Day71NotificationListener({Key key}) : super(key: key);
@override
_Day71NotificationListenerState createState() =>
_Day71NotificationListenerState();
}
class _Day71NotificationListenerState extends State<Day71NotificationListener> {
String message = 'Please Scroll the list to Usage';
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
Container(
height: 50.0,
color: Colors.green,
child: Center(
child: Text(message),
),
),
Expanded(
// ? What is NotificationListener....
/**
* ! NotificationListener is the listener for the activity in the ui element....
*/
child: NotificationListener<ScrollNotification>(
// ! here i am used the scroll notification....
onNotification: (ScrollNotification notification) {
print(
"$notification"); //! I just print the notification call back....
if (notification is ScrollStartNotification) {
// Check ScrollNotification is StartNotification....
setState(() {
message = "Scroll Start"; // ! print the Scroll Start....
});
} else if (notification is ScrollUpdateNotification) {
// Check ScrollNotification is UpdateNotification....
setState(() {
message =
"Scroll Update"; // ! print the Scroll Update....
});
} else if (notification is ScrollEndNotification) {
// Check ScrollNotification is EndNotification....
setState(() {
message = "Scroll End"; // ! print the Scroll End....
});
}
return true;
},
child: ListView.builder(
itemCount: 30,
itemBuilder: (context, index) {
return ListTile(title: Text("Index : $index"));
},
),
),
),
],
),
),
appBar: AppBar(
title: Text('NotificationListener'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.help),
onPressed: () async {
const url =
'https://github.com/sanjaysanju618/100-Days-Of-Flutter-Widgets/' +
'blob/master/hundred_days_of_flutter_widget/' +
'lib/day071_notification_listener.dart';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
)
],
),
);
}
}