Reputation: 1323
I am trying to share an image that has been loaded into a GridView previously with the following code:
return FocusedMenuHolder(
blurSize: 2,
blurBackgroundColor: Colors.black12,
menuWidth: 200,
duration: Duration(milliseconds: 200),
onPressed: (){},
menuItems: <FocusedMenuItem>[
FocusedMenuItem(title: Text("Share"),trailingIcon: Icon(Icons.share) ,onPressed: (){}),
FocusedMenuItem(title: Text("Delete",style: TextStyle(color: Colors.redAccent),),trailingIcon: Icon(Icons.delete,color: Colors.redAccent,) ,onPressed: (){}),
],
child: Container(
margin: const EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Colors.black12,
image: DecorationImage(
image: FileImage(File(localFiles[index])), fit: BoxFit.cover,
),
),
),
);
Then on a long press from the opened FocusedMenu, I would like to pick share and share that file with the flutters share package. I however have no idea how I should go on about getting the path of the file loaded in the FocusedMenuHolder
Upvotes: 0
Views: 60
Reputation: 12363
Assuming your list is "localFiles", and you want to share the path, meaning the path stored locally on your device. In your on pressed:
Use your share function that you want, and pass this path to it:
localFiles[index].filePath
.
Upvotes: 1