baymax 1.0.0
baymax: ^1.0.0 copied to clipboard
Shared, app-agnostic Flutter building blocks: a typed network client, an adaptive app shell, themeable design tokens, and environment config.
import 'package:baymax/baymax.dart';
import 'package:flutter/material.dart';
void main() {
EnvConfig.init(
environment: Environment.dev,
baseUrls: {
Environment.dev: 'https://dev.example.com',
Environment.qa: 'https://qa.example.com',
Environment.prod: 'https://example.com',
},
);
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: AppGlobals.navigatorKey,
scaffoldMessengerKey: AppGlobals.scaffoldMessengerKey,
theme: ThemeData(extensions: [AppColors.defaults(), AppTypography.defaults()]),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _selectedIndex = 0;
static const _pages = [Center(child: Text('Home')), Center(child: Text('Settings'))];
@override
Widget build(BuildContext context) {
return AdaptiveScaffold(
body: _pages[_selectedIndex],
selectedIndex: _selectedIndex,
onDestinationSelected: (index) => setState(() => _selectedIndex = index),
barDestinations: const [
NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
NavigationDestination(icon: Icon(Icons.settings), label: 'Settings'),
],
railDestinations: const [
NavigationRailDestination(icon: Icon(Icons.home), label: Text('Home')),
NavigationRailDestination(icon: Icon(Icons.settings), label: Text('Settings')),
],
);
}
}