fluent_environment 0.7.0
fluent_environment: ^0.7.0 copied to clipboard
Package that provides a way to register your environment globally and display it.
import 'package:fluent_environment/fluent_environment.dart';
import 'package:flutter/material.dart';
import 'app_environment.dart';
void main() async {
await Fluent.build([EnvironmentModule(environment: AppEnvironment())]);
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
static final navigatorKey = GlobalKey<NavigatorState>();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Fluent Environment Example',
navigatorKey: navigatorKey,
builder: (context, child) => EnvironmentBanner(
enableInspector: true,
configValuesLabel: 'Custom Config Label',
noValuesLabel: 'Custom No Values Message',
navigatorKey: navigatorKey,
child: child!,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
final environment = Fluent.get<EnvironmentApi>().environment;
return Scaffold(
appBar: AppBar(title: const Text('Fluent Environment')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Environment: ${environment.name}"),
const SizedBox(height: 16),
const Text(
"Long press the environment banner to see the inspector",
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () {
Fluent.get<EnvironmentApi>().showInspector(
context,
configValuesLabel: 'Manual Config Label',
noValuesLabel: 'Manual No Values Message',
);
},
child: const Text("Show Inspector Manually"),
),
],
),
),
);
}
}