I can't seem to find this one. Is it possible to add the number on the app icon? (windows desktop)
For example this is Telegram on windows:
You can use package:windows_taskbar to add badge (overlay icon) to your Flutter Windows app's taskbar icon.
You have to create icons yourself though, maybe "1", "2", "3"... "9" & "9+" like most applications (as .ico files).
It's very easy to use as well.
Add in pubspec.yaml
dependencies:
windows_taskbar: ^1.1.0
Set Icon
WindowsTaskbar.setOverlayIcon(
ThumbnailToolbarAssetIcon('assets/red_slash.ico'),
tooltip: 'Stop',
);
Don't forget to add the icon file to your pubspec.yaml assets.
Remove Icon
WindowsTaskbar.resetOverlayIcon();
NOTE: I'm developer of the package.
These badges are autocreated on notification. There arent much packages for notifications in windows. You can give this a try.
quick_notify: ^0.2.1
QuickNotify.notify(
title: 'My title',
content: 'My content',
);
Related
I am using flutter_local_notifications: ^9.7.0 to show notification and that's really nice package, using that package I am available to get badge with icon "1" when notification pops up. What I would like to ask.. instead of showing "1" badge, I would like to show dot badge. Is there a way to do that using flutter_local_notifications or any other package ?
Notification Badges are Platform's entity & unfortunately, you can not do anything to change it.
As mentioned in Android docs
These dots appear by default in launcher apps that support them and there's nothing your app needs to do.
How to use custom icon in flutter, using android studio! I need to know what we want to do in pubspec.yaml. Because I got an error in pubspec.yaml, cant view a icon in our program.
It can help if you specify what sort of icon you are trying to add, and if you share some of your pubspec file. Are we talking about an app icon (using a package like flutter_launcher_icons) or icons to use within the app (like the ones created via fluttericon.com).
I'll assume you're talking about launcher icons.
First make sure you have the package:
https://pub.dev/packages/flutter_launcher_icons
In the root of your pubspec.yaml file, you can add lines like:
flutter_icons:
android: true
ios: true
image_path: "assets/myIcon.png"
adaptive_icon_background: "#ffffff"
adaptive_icon_foreground: "assets/myIconForeground.png"
This will use myIcon.png for the iOS app, and apply the foreground image on a white background for Android (where depending on your phone, a circular or square icon can be used).
Now you may notice the asset paths, you can also add the icons as assets to your app such that you can use them elsewhere.
flutter:
...
assets:
- assets/myIcon.png
- assets/myIconForeground.png
After which you should be able to run the plugin and generate your native icons:
flutter pub run flutter_launcher_icons:main
Getting api response like this
"sample_response":
{
"id": 1,
"icon": "fa-ambulance",
}
for static icon i used
icon: FaIcon(FontAwesomeIcons.gamepad),
How to load icon based on the json response
This is not supported by Font Awesome Flutter.
There is another package to help you with that: Icons Helper
However, if you try right now, you will see that Icons Helper refers to an adobe icon that does not exist anymore. It has been removed from the package in the master on Git but not yet on PubDev.
You could also just integrate icons_helper.dart in your project and maintain the map you need in your app.
I'm looking for a way to show an app icon badge when a user receives a push notification.
I'm using the Firebase_messaging plugin for flutter for the handling of the push notifications and flutter_app_badger for the app icon badges.
But I want to combine the two so that the number is set on the icon without opening the app. Is it possible to make this happen? Or am I overlooking something obvious from the firebase_messaging plugin?
Sorry for the horrible explanation. I hope someone can help me with this issue.
App icon badge depends on the Application Launcher
Some of the Android Application Launcher includes this functionality by default, You can check this on Settings->Apps->Notification
Attached image
FYI
How to show notification count on app icon like Facebook?
How does Facebook add badge numbers on app icon in Android?
adding notification badge on app icon in android
My suspicion is that you have an icon that isn't compatible with the icon guidelines in your device. I suggest trying https://pub.dev/packages/flutter_launcher_icons to make icons for your device.
I think you try to create stream when run app to real time listen doc changes in Firestore. Read here How to listen for document changes in Cloud Firestore using Flutter?
And the icon can be update in background but without opening app is impossible I think.
I don't have a direct answer because I haven't encountered this issue before, but this might fix your problem
Ensure that you have defined the icon for your application properly - for flutter, here are the steps you should have:
Import the package into your pubsec.yaml file - it should be called flutter_launcher_icons: "^0.8.0" and imported under the dev-dependencies section of the pubspec.yaml file.
After the dev-dependencies section, add a new section for flutter icons as so:
flutter_icons:
ios: true
android: true
image_path_ios: "{Icon File Path}"
image_path_android: "{Icon File Path}"
Hopefully this helps, and good luck with fixing your issue!
Using https://pub.dev/packages/firebase_messaging for notifications ,
for Android Background notifications you can add this in your AndroidManifest.xml file in your application tag. And make sure you have androidlogo.png (this is example name) present in your drawable folder.
<application>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/androidlogo" />
</application>
In case of foreground notifications, you must be using Flutter Local Notifications, so you can provide the same while initializing like
var initializationSettingsAndroid = new AndroidInitializationSettings('androidlogo');
flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onNotificationClicked);
And for application icon you can use this library https://pub.dev/packages/flutter_launcher_icons which is also suggested by answers above.
In case of iOS, your launcher icon will your notification icon.
And for display of badge icon you can use https://pub.dev/packages/flutter_app_badger. (For supported phones).
So using all this you will get both app icon with badge and notification icon as your app icon (or specified by you).
You can control the badge count from the notification payload.
If you send a notification manually from Firebase Console, you can set the badge count on Additional options step:
If you send it programmatically, add this payload (iOS example):
{"aps":{"alert":"Enter your message","badge":1,"sound":"default"}}
For more payload options, check out FCM documentation
I am trying to complete this Flutter Code Lab, but the icons do not appear in my application. But they appears in Android Studio code:
I have been included the lib in my file pubspec.yaml
name: startup_namer
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
english_words: ^3.1.0
But result is this:
My main.dart file looks like this:
// Add the heart icons to the ListView.
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
.....
Widget _buildRow(WordPair pair) {
final bool alreadySaved = _saved.contains(pair);
return new ListTile(
title: new Text(
pair.asPascalCase,
style: _biggerFont,
),
trailing: new Icon(
alreadySaved ? Icons.favorite : Icons.favorite_border,
color: alreadySaved ? Colors.red : null,
size: 22.0,
),
onTap: () {
setState(() {
if (alreadySaved) {
_saved.remove(pair);
} else {
_saved.add(pair);
}
});
},
);
}
}
I thought that is because I use iOS emulator, but when I tried with Android emulator the result was the same.
(Copied from the comments)
You need to set uses-material-design: true in pubspec.yaml for the icons to be included in the app.
In my case, I have written uses-material-design: true in pubspec.yaml file. I am able to solve this problem by restarting the Android emulator. You can also try by uninstalling old build from your emulator and then installing the new one.
This is little weird behavior, but it works for me.
Hot reloading does not show changes in resources. Press the stop button square red color in the top action menu bar of android studio and run the app again.
It works.
Please try:
Stopping the app
Running flutter clean in your app directory
Deleting the app from your simulator / emulator / device
Rebuild & Deploy the app.
If you are using the FlutterIcons library, make sure that your font-family in your pubspec.yaml matches the one declared in the my_flutter_app_icons.dart file.
I assume we're talking about the flutter_icons package?
I had to kill the app entirely and reinstall it and they started working for me. Not sure why a hot reload didn't do the trick.
Just delete the App from emulator/physical device on which you are working and again build the app.
It works for me and will surely works for you.
Add the following to your pubspec.yaml:
flutter:
uses-material-design: true
Took me a while to figure out based on the answers above that uses-material-design is a property of flutter, not of the root.
Icon changing to Chinese character was resolved by adding the correct path to the fonts folder. Specify, the correct path to your fonts folder by providing proper indentations:
Flutter Clean
Remove Build From your testing device/Emulator
Run the app
You need to set uses-material-design: true in pubspec.yaml for the icons to be included in the app.
Be sure to have a uses-material-design: true entry in the flutter section of your pubspec. yaml file. It allows you to use the predefined set of Material icons. Many Material Design widgets need to be inside of a MaterialApp to display properly, in order to inherit theme data.
this was issue for me
Make sure in pubspec.yaml file all the images and fonts have correct path and if you have added new image recently try to remove that and then rebuild
The icons were loading normally on all devices except android for me. To fix it I simply:
Before
Icon(
Icons.chevron_left,
size: 40.0,
color: Colors.white,
),
After
Icon(
MdiIcons.chevronLeft,
size: 40.0,
color: Colors.white,
),
Steps
Add to pubspec yahml
dependencies:
material_design_icons_flutter: ^4.0.5955
Add this to the file you want the icon
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
Instead of Icons.NameHere use MdiIcon.NameHere
if all the above not worked then run
flutter pub run flutter_launcher_icons:main
The problem started in my project when I included my app within GetMaterialApp instead of MaterialApp Widget. All Material icons started to look like [X].