flutter_plugin_device_apps
flutter_plugin_device_apps copied to clipboard
Cannot use Image.memory(app.icon); in the project
Is it possible to get the applications icon by any other method?
Why can't you use this method?
Can you please tell me how to get app icon based on the app name?
You just have to cast the Object from Application
to ApplicationWithIcon
Check this out https://github.com/g123k/flutter_plugin_device_apps/issues/20#issuecomment-661076132
@g123k i want to save the app.icon loaclly and use it later but not able to use it as it's saying
type 'List<dynamic>' is not a subtype of type 'Uint8List
How can i solve this?
Just Find a solution and don't know why it works ! But there is a problm! Sometimes it works and sometimes doesn't! take app.icon in a variable before using it in Image.memory()
ApplicationWithIcon iconx = app as ApplicationWithIcon;
var icon = iconx.icon;
Image.memory(icon);
My quick workaround as @jspw mentioned, so was something like that
icon: snapshot.data[index] is ApplicationWithIcon
? CircleAvatar(
backgroundImage: MemoryImage((snapshot
.data[index] as ApplicationWithIcon)
.icon),
backgroundColor: Colors.white,
)
: null,
result:"
I don't know if there is still a problem, because the issue is still open, but you can simply get all apps by creating a simple Future:
Future<List<Application>> _getApps() async { return await DeviceApps.getInstalledApplications( includeSystemApps: true, onlyAppsWithLaunchIntent: true, includeAppIcons: true); }
(Don't forget to include the includeAppIcons: true
property.)
Now you've got a List of "Application's".
Now you can simply cast an 'Application' to an 'ApplicationWithIcon' like this:
ApplicationWithIcon applicationWithIcon = apps[index] as ApplicationWithIcon;
The only thing you have to do now is to use the "icon" value in the "Image.memory()" widget to display it on the screen.
Image.memory(applicationWithIcon.icon)