skip to Main Content

When the user clicks on the button in my Flutter program, I want to open "E:Downloads1.fbx" file on the Windows 3D viewer (Default software – windows).

But the file location is not included in pubspec.yaml file. I cannot find a way to do this. Is there any package or any way to do this?

2

Answers


  1. Chosen as BEST ANSWER

    @moulte answer is correct for normal software such as Chrome, Zoom, etc.

    But, In my case, Windows 3D viewer is not normal software. It's a default one. Can't find the file location of the 3D viewer. (actually, we can find it but, If you use it, you just want to get administrator permissions for your Flutter windows.)

    So, I found this method to do my task.

    Created Function

    void openFile(String filePath) {
        Process.run('cmd', ['/c', 'start', '', filePath]);
      }
    

    Called it when user clicks the button,

    onPressed: () {
              String filePath = r'E:Downloadsgo.fbx';
              openFile(filePath);
                                                },
    

    Now, It's on with 3D viewer.


  2. You could use the process class to run the executable you want, the seconds param is the list of args to pass to the executable.
    Give it the file to open. For example something like this should work :

    import 'dart:io';
    
    
    void main() async {
    
        Process.run("C:/Program Files/Google/Chrome/Application/chrome.exe",["pdf.pdf"]);
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search