How to test a method that uses package_info in Flutter?
Like Günter said, you can mock PackageInfo by installing a mock method handler in the MethodChannel for the plugin:
void packageInfoMock() { const MethodChannel('plugins.flutter.io/package_info').setMockMethodCallHandler((MethodCall methodCall) async { if (methodCall.method == 'getAll') { return <String, dynamic>{ 'appName': 'ABC', // <--- set initial values here 'packageName': 'A.B.C', // <--- set initial values here 'version': '1.0.0', // <--- set initial values here 'buildNumber': '' // <--- set initial values here }; } return null; });}