import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; import 'package:wyatt_ui_kit_example/buttons/buttons.dart'; import 'package:wyatt_ui_kit_example/cards/cards.dart'; const String title = 'Wyatt UIKit Example'; class Home extends StatefulWidget { const Home({super.key, this.forceIndex = 0}); final int forceIndex; @override State createState() => _HomeState(); } class _HomeState extends State { final List pages = const [Cards(), Buttons()]; int currentIndex = 0; @override void initState() { currentIndex = widget.forceIndex; super.initState(); } @override Widget build(BuildContext context) => Scaffold( drawer: Drawer( child: ListView( padding: EdgeInsets.zero, children: [ ListTile( title: const Text('Cards'), onTap: () { if (currentIndex != 0) { setState(() { currentIndex = 0; }); Navigator.pop(context); } }, ), ListTile( title: const Text('Buttons'), onTap: () { if (currentIndex != 1) { setState(() { currentIndex = 1; }); Navigator.pop(context); } }, ), ], ), ), appBar: AppBar( title: const Text(title), actions: [ Switch.adaptive( value: AdaptiveTheme.of(context).isDefault, onChanged: (_) { AdaptiveTheme.of(context).isDefault ? AdaptiveTheme.of(context).setDark() : AdaptiveTheme.of(context).setLight(); }, ) ], ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: pages[currentIndex], ), ); }