Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Stress_detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Himali Aryal
Stress_detection
Commits
a34018b4
Commit
a34018b4
authored
4 years ago
by
Himali Aryal
Browse files
Options
Downloads
Patches
Plain Diff
sheduled notification
parent
6ac55a35
No related branches found
No related tags found
1 merge request
!8
scheduled notification
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
android/app/src/main/res/drawable/app_icon.png
+0
-0
0 additions, 0 deletions
android/app/src/main/res/drawable/app_icon.png
lib/ui/common/notification_provider.dart
+89
-11
89 additions, 11 deletions
lib/ui/common/notification_provider.dart
with
89 additions
and
11 deletions
android/app/src/main/res/drawable/
stress-test-
icon.png
→
android/app/src/main/res/drawable/
app_
icon.png
+
0
−
0
View file @
a34018b4
File moved
This diff is collapsed.
Click to expand it.
lib/ui/common/notification_provider.dart
+
89
−
11
View file @
a34018b4
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_app/ui/common/slide_up_route.dart'
;
import
'package:flutter_app/ui/entries/add_entries.dart'
;
import
'package:flutter_local_notifications/flutter_local_notifications.dart'
;
import
'package:rxdart/subjects.dart'
;
...
...
@@ -14,16 +19,47 @@ class _NotificationProviderState extends State<NotificationProvider> {
int
val
;
@override
// void initState() {
// super.initState();
// var androidInitilize = new AndroidInitializationSettings('app_icon');
// var iOSinitilize = new IOSInitializationSettings();
// var initilizationsSettings =
// new InitializationSettings(androidInitilize, iOSinitilize);
// fltrNotification = new FlutterLocalNotificationsPlugin();
// fltrNotification.initialize(initilizationsSettings,
// onSelectNotification: notificationSelected);
// }
void
initState
()
{
super
.
initState
();
var
androidInitilize
=
new
AndroidInitializationSettings
(
'app_icon'
);
var
iOSinitilize
=
new
IOSInitializationSettings
();
var
initilizationsSettings
=
new
InitializationSettings
(
android:
androidInitilize
,
iOS:
iOSinitilize
);
fltrNotification
=
new
FlutterLocalNotificationsPlugin
();
fltrNotification
.
initialize
(
initilizationsSettings
,
onSelectNotification:
notificationSelected
);
}
Future
_showNotification
()
async
{
var
androidDetails
=
new
AndroidNotificationDetails
(
"Notification ID"
,
"Diary notification provider"
,
"This is reminder to add daily diary to your app"
,
importance:
Importance
.
max
,
// playSound: true,
// sound: RawResourceAndroidNotificationSound('Notification sound')
);
var
iSODetails
=
new
IOSNotificationDetails
();
var
generalNotificationDetails
=
new
NotificationDetails
(
android:
androidDetails
,
iOS:
iSODetails
);
// await fltrNotification.show(
// 0, "Task", "You created a Task", generalNotificationDetails, payload: "Task");
var
scheduledTime
;
if
(
_selectedParam
==
"Hour"
)
{
scheduledTime
=
DateTime
.
now
()
.
add
(
Duration
(
hours:
val
));
}
else
if
(
_selectedParam
==
"Minute"
)
{
scheduledTime
=
DateTime
.
now
()
.
add
(
Duration
(
minutes:
val
));
}
else
{
scheduledTime
=
DateTime
.
now
()
.
add
(
Duration
(
seconds:
val
));
// scheduledTime = Timer.periodic(scheduledTime,(timer){});
}
fltrNotification
.
schedule
(
1
,
"DIARY NOTIFICATION"
,
task
,
scheduledTime
,
generalNotificationDetails
);
}
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -120,6 +156,30 @@ class _NotificationProviderState extends State<NotificationProvider> {
child:
Text
(
"4"
),
value:
4
,
),
DropdownMenuItem
(
child:
Text
(
"5"
),
value:
5
,
),
DropdownMenuItem
(
child:
Text
(
"6"
),
value:
6
,
),
DropdownMenuItem
(
child:
Text
(
"7"
),
value:
7
,
),
DropdownMenuItem
(
child:
Text
(
"8"
),
value:
8
,
),
DropdownMenuItem
(
child:
Text
(
"9"
),
value:
9
,
),
DropdownMenuItem
(
child:
Text
(
"10"
),
value:
10
,
),
],
hint:
Text
(
"Select Value"
,
...
...
@@ -130,10 +190,15 @@ class _NotificationProviderState extends State<NotificationProvider> {
onChanged:
(
_val
)
{
setState
((){
val
=
_val
;
}
);}
}
);
}
),
],
),
RaisedButton
(
onPressed:
_showNotification
,
child:
new
Text
(
'REMIND ME'
),
)
],
),
],
...
...
@@ -141,4 +206,17 @@ class _NotificationProviderState extends State<NotificationProvider> {
),
);
}
Future
notificationSelected
(
String
payload
)
async
{
showDialog
(
context:
context
,
builder:
(
context
)
=
>
AlertDialog
(
content:
Text
(
"Notification Clicked
$payload
"
),
),
);
GestureDetector
(
onTap:
()
=
>
Navigator
.
of
(
context
)
.
push
(
SlideUpRoute
(
widget:
AddEntry
())),
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment