A flutter plugin which will help you to get metadata values defined in AndroidManifest.xml (Android) or info.plist (iOS).
Created by Shivam Mishra @shivbo96
- Depend on it Add this to your package's pubspec.yaml file:
dependencies:
platform_metadata: <VERSION>
- Install it You can install packages from the command line: with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.
- Import it Now in your Dart code, you can use:
import 'package:platform_metadata/platform_metadata.dart';
place inside your android manifest file
<meta-data android:name="meta_key" android:value=" meta_value from android " />
place inside your iOS info.plist
<key>meta_key</key>
<string> meta_value from ios </string>
Future<void> getMetaData() async {
String metaDataValue;
try {
metaDataValue = await PlatformMetadata.getMetaDataValue('meta_key') ?? '';
} on PlatformException {
metaDataValue = 'Failed to get metaDataValue.';
}
if (!mounted) return;
setState(() {
_metaDataValue = metaDataValue;
});
}