developer_keyron
developer_keyron

Reputation: 1

How to get app build number in flutter from pubspec.yaml?

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

enter image description here

Upvotes: 0

Views: 4974

Answers (1)

Minjin Gelegdorj
Minjin Gelegdorj

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

Related Questions