environment_widget 1.2.0 copy "environment_widget: ^1.2.0" to clipboard
environment_widget: ^1.2.0 copied to clipboard

Flutter package to set environment.

example/lib/main.dart

import 'package:environment_widget/environment_widget.dart';
import 'package:flutter/material.dart';

Future<Widget> run({
  required Environment environment,
}) async {
  WidgetsFlutterBinding.ensureInitialized();

  //Load and check all you need

  return Application(
    environment: environment,
  );
}

class Application extends StatelessWidget {
  final Environment environment;

  const Application({
    required this.environment,
  });

  @override
  Widget build(BuildContext context) {
    return this.environment.widget(
          appWidget: MaterialApp(
            theme: this.environment.lightThemeData,
            darkTheme: this.environment.darkThemeData,
            debugShowCheckedModeBanner: false,
            home: Home(
              baseURL: this.environment.baseUrl,
            ),
          ),
        );
  }
}

class Home extends StatelessWidget {
  final String? baseURL;

  const Home({
    this.baseURL,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Environment Widget'),
      ),
      body: Center(
        child: Text(
          this.baseURL ?? '',
        ),
      ),
    );
  }
}
1
likes
140
points
48
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package to set environment.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on environment_widget