1

When the user clicks on the button in my Flutter program, I want to open "E:\Downloads\1.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 2

0

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"]);
}
Sign up to request clarification or add additional context in comments.

2 Comments

in this case , file location must include in pubspec.yaml file.
use something like the package filepicker to ask the location of a file to the user, you will get the selected path and use Process.run to run it
0

@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:\Downloads\go.fbx';
          openFile(filePath);
                                            },

Now, It's on with 3D viewer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.