Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter execute binary

Tags:

flutter

dart

How to execute binary file in flutter? I have put the binary into assets and added to my code function to 'unpack' it (How do I get the Asset's file path in flutter?).

The file is in the app data folder:

generic_x86:/data/data/com.example.hidden/app_flutter # ls
binaryfile flutter_assets 
generic_x86:/data/data/com.example.hidden/app_flutter # 

However when I try executing it using the Process.run it says Permission denied. When I chmod +x or chmod 777 it using root shell, it says No such file or directory. However I would prefer some no root method to do this.

How can I properly execute prebuilt binaries in Flutter? Thanks

like image 946
Makalone LOgman Avatar asked Apr 20 '19 14:04

Makalone LOgman


Video Answer


1 Answers

I think the way to do this is to copy your binary file from assets to a local directory, as obtained by final directory = await getApplicationDocumentsDirectory(), and to then call Process.run with that file as the command argument.

Even then, I don't believe you can run anything as root this way, and your access to the file system may be quite limited.

like image 60
Bram Avatar answered Dec 13 '22 03:12

Bram