env_native 1.0.0 copy "env_native: ^1.0.0" to clipboard
env_native: ^1.0.0 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(MyApp());
}

class MyApp extends StatefulWidget {
  @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
120
pub points
55%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on env_native