flutter awesome notification give function to button - flutter

i want to give some action to my notification button but i cannot get it to work, i want to give cancel download from my dio service
here is my code
notification.createNotification(
content: NotificationContent(
//simgple notification
id: id,
channelKey: 'basic', //set configuration wuth key "basic"
title: title,
body: body,
payload: {
"name": "layar",
},
icon: 'resource://drawable/ic_downloading',
autoDismissible: false,
notificationLayout: NotificationLayout.ProgressBar,
progress: progress,
fullScreenIntent: true,
backgroundColor: MyThemes.colorBlue,
),
actionButtons: [
NotificationActionButton(
key: "cancel",
label: "Cancel",
actionType: ActionType.DismissAction,
),
NotificationActionButton(
key: "pause",
label: "Pause",
),
],
);

Related

How can I play this function in background services in flutter

How can I play this function in background services in flutter?
Kindly elaborate or also attach documentation or video link if possible.
I'm trying to play some music from a dependency named assets_audio_player.
I tried to use the didAppLifeCycleChange but in this way, I was facing a new
issuer it plays 2 songs. now I want to play songs directly in the background does not matter
app is in background or in foreground
void setupPlaylist() async {
await audioplayer.open(
showNotification: true,
Playlist(audios: [
Audio(
'assets/1.mp4',
metas: Metas(
title: "Bazz aa by YS",
artist: 'Talha',
image: const MetasImage.network(
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg'),
),
),
// Audio(SongsList[2].,
// metas: Metas(
// title: "Bazz01",
// artist: 'Talha',
// )),
Audio.network(
'https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview125/v4/09/17/bb/0917bbe1-58c3-6252-d00e-9b70d42ef5dc/mzaf_2269500085377778268.plus.aac.p.m4a',
metas: Metas(
id: 'Online',
title: 'Online',
artist: 'Florent Champigny',
album: 'OnlineAlbum',
// image: MetasImage.network('https://www.google.com')
image: const MetasImage.network(
'https://i.dawn.com/large/2021/09/61399fb500900.png'),
),
),
Audio(
'assets/2.mp4',
metas: Metas(
title: "Bazz aa by YS",
artist: 'Talha',
image: const MetasImage.network(
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg'),
),
),
Audio('assets/3.mp4',
metas: Metas(
title: "Bazz aa song",
artist: 'Talha',
image: const MetasImage.network(
'https://www.thenews.com.pk/assets/uploads/updates/2021-12-27/920292_6757937_hgjhj_updates.jpg'),
)),
Audio('assets/1.mp4',
metas: Metas(
title: "Bazz03",
artist: 'Talha',
image: const MetasImage.network(
'https://www.thenews.com.pk/assets/uploads/updates/2021-12-27/920292_6757937_hgjhj_updates.jpg'),
)),
]),
autoStart: true,
loopMode: LoopMode.playlist,
);
}

Add Action to AndroidNotificationDetails

I would like to add a button to my notification, I was able to get it displayed but I can't find the documentation on how to add an action to the button press
const androidNotification = AndroidNotificationDetails(
'Bla', 'Bla',
icon: 'ic_bg_service_small',
ongoing: true,
actions: [AndroidNotificationAction("stop", "Stop")]);
flutterLocalNotificationsPlugin.show(
888,
'MyService',
'bla',
const NotificationDetails(android: androidNotification),
);
You need to use this plugin to make action in notifications https://pub.dev/packages/awesome_notifications
void _showNotificationWithButton() {
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Simple Notification',
body: 'Simple body'),
actionButtons: <NotificationActionButton>[
NotificationActionButton(key: 'yes', label: 'Yes'),
NotificationActionButton(key: 'no', label: 'No'),
],
);
}

awesome push notification with fcm

i am lost at some point,
i am try to figure out how to use this plugin plugin here
what should use to reply this:
this is working on fcm fine but i am trying to switch from fcm because of the reply like whatsApp
FirebaseMessaging.onMessage.listen
FirebaseMessaging.onMessageOpenedApp.listen
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage message) {
});
you can use action button:
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Action button title',
body: 'Simple body',
),
actionButtons: [
NotificationActionButton(
key: "REPLY",
label: "Reply",
autoCancel: true,
enabled: true,
buttonType: ActionButtonType.InputField,
icon: "resource://drawable/logo"),
],
);

set custom height and width to sweat-alert

I have applied sweetalert in my project my application is in landscape direction and sweetalert take the full screen I want to set custom width and height to sweetalert.
SweetAlert.show(context,
title: "Just show a message",
subtitle: "Sweet alert is pretty",
style: SweetAlertStyle.confirm,
showCancelButton: true, onPress: (bool isConfirm) {
if (isConfirm) {
SweetAlert.show(context,style: SweetAlertStyle.success,title: "Success");
// return false to keep dialog
return false;
}
});
There is no any option according to my assessment for your question. but I think rflutter_alert is the best option to use instead of sweetalert here you can use the width and height to customize it. Hope that will help you. you can add multiple buttons in buttons: [],
import 'package:rflutter_alert/rflutter_alert.dart';
Alert(
context: context,
type: AlertType.error,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"COOL",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
width: 120,
)
],
).show();
Okay, wrap your string with three quote (''' String '''), Add space or new lines what you want base on your expected height.
https://api.dartlang.org/stable/2.5.0/dart-core/String-class.html
SweetAlert.show(
context,
title: '''
Just show a message
''',
subtitle: '''
Sweet alert is pretty
''',
style: SweetAlertStyle.confirm,
showCancelButton: true,
onPress: (bool isConfirm) {
if (isConfirm) {
SweetAlert.show(context,
style: SweetAlertStyle.success, title: "Success");
// return false to keep dialog
return false;
}
},
);

Search Field on a Dialog - SAPUI5

Good Morning!
I an start working with SAPUI5
How can I set a Search field(sap.m.SearchField) on a Dialog?
Thank You
I suggest:
new Dialog({
title: 'Available Products',
content: new List({
items: {
path: '/ProductCollection',
template: new StandardListItem({
title: "{Name}",
counter: "{Quantity}"
})
}
}),
beginButton: new Button({
text: 'Close',
press: function() {
that.pressDialog.close();
}
}),
subHeader: [
new sap.m.Bar({
contentMiddle: [
new sap.m.SearchField({
width: "100%",
value: "Search Term"
})
]
})
]
});