0

I want to get my native dart software build and version number which exists in pubspac.yaml

enter image description here

My software gets converted in the end to executable using the dart2native so I guess that the final executable file does not include the actual pubspec.yaml file.

I can't use package_info_plus as suggested in many places because I run native Dart code and not Flutter app.

Guy Luz
  • 3,372
  • 20
  • 43

1 Answers1

0

You can read a pubspec file with pubspec_parse. Then you can retrieve the version number.

final file = File('pubspec.yaml');

final content = Pubspec.parse(await file.readAsString());

print(content.version); // 1.1.2+41
mrgnhnt96
  • 3,562
  • 1
  • 17
  • 36
  • Do you think that I can read it even when got transformed into executable and the pubspec.yaml got removed? – Guy Luz Nov 24 '21 at 19:25
  • If you were to read the file's contents `file.readAsString()` before the file was deleted, you would be able to use it. But you can't read a file that doesn't exist any more – mrgnhnt96 Nov 24 '21 at 19:39