I am trying to get list of installed apps and able to get it using mentioned code. How to make this forEach information into Json list to save it to server as json
Future<void> getinstalledAppList() async{
List<Application> apps = await DeviceApps.getInstalledApplications();
apps.forEach((app) {
var jsonList = app.appName;
print(jsonList);
});
}
Output of print is like below :
I/flutter ( 5465): WooCommerce
I/flutter ( 5465): Amazon
I/flutter ( 5465): Weather
I/flutter ( 5465): OfficeSuite
I need output like:
{'WooCommerce', 'Amazon', 'Weather' , 'OfficeSuite'}
2
Answers
You can define a global app name list. And push items into this list. After that, you can easily send it to the server. It will look like this:
You can use the following code which will extract appName from the application and make a list of it. You can directly write that list If you want JSON array in string format then you can make use of jsonEncode()