env_native 1.0.1 copy "env_native: ^1.0.1" to clipboard
env_native: ^1.0.1 copied to clipboard

A plugin to get native variables from Android resources and iOS configs

example/lib/main.dart

import 'dart:async';

import 'package:env_native/env_native.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  String _message = 'Loading...';

  @override
  void initState() {
    super.initState();
    getMessage();
  }

  Future<void> getMessage() async {
    String message;
    try {
      final s = await EnvNative.getString('test_string');
      final i = await EnvNative.getInt('test_int');
      message = '$s, $i';
    } on PlatformException catch (e) {
      message = 'Failed to get variables: $e';
    }

    if (!mounted) return;

    setState(() {
      _message = message;
    });
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Center(
            child: Text(_message),
          ),
        ),
      );
}
2
likes
150
points
1.3k
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin to get native variables from Android resources and iOS configs

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on env_native