Reputation: 1
I need to access version from pubspec.yaml and display it in a screen. How can I get this possibly without using any packages. Any answer would be highly appreciated. Thank You
Upvotes: 0
Views: 4974
Reputation: 782
Try this package. According to the example, usage is in below.
import 'package:package_info_plus/package_info_plus.dart';
...
// Be sure to add this line if `PackageInfo.fromPlatform()` is called before runApp()
WidgetsFlutterBinding.ensureInitialized();
...
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
Or check this answer
Upvotes: 2