env_reader 2.0.3 copy "env_reader: ^2.0.3" to clipboard
env_reader: ^2.0.3 copied to clipboard

Read, encrypt, or generate environment variables from a .env file into an obfuscated Dart model.

example/lib/main.dart

import 'package:env_reader/env_reader.dart';
import 'package:example/src/env_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Future<void> main(List<String> arguments) async {
  WidgetsFlutterBinding.ensureInitialized();
  await Env.load(
    EnvStringLoader(await rootBundle.loadString('assets/env/.env')),
    "MyOptionalSecretKey",
  );
  runApp(
    const MaterialApp(
      title: "Env Reader",
      debugShowCheckedModeBanner: false,
      home: MyApp(),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(Env.read<String>("DATABASE_URL") ?? "Oops"),
            Text(EnvModel.apiKey),
          ],
        ),
      ),
    );
  }
}
23
likes
160
pub points
2%
popularity
screenshot

Publisher

verified publisherinidia.app

Read, encrypt, or generate environment variables from a .env file into an obfuscated Dart model.

Homepage
Repository (GitHub)
View/report issues

Topics

#utility #env

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

args, cryptography, http

More

Packages that depend on env_reader