Search code examples
flutterxcodedart

Recommended way to include binaries in flutter application and how to access them


As there doesn't seem to exist much regarding this I meant to ask what is recommended in this case? I have been including it in /lib/bin, accessing it using join(dirname(Platform.script.toFilePath()), 'lib', 'bin', 'binary');

However, this does not seem to be working in the general case. Does anyone have experience with this?


Solution

  • After a lot of experimentation, the following seems to be the best way to achieve it:

        Platform.resolvedExecutable.replaceFirst(RegExp(r'/[^/]+$'), ''),
        '..',
        'Frameworks',
        'App.framework',
        'Resources',
        'flutter_assets',
        'assets',
        'bin',
        'yourBinary');
    

    This can be used after adding assets/bin/ to your pubspec.yaml