Fix providers
This commit is contained in:
@@ -17,13 +17,8 @@ class MyExampleApp extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
title: 'GymLink Example App',
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: ChangeNotifierProvider(
|
||||
create: (_) => GymLinkProvider(),
|
||||
child: Consumer<GymLinkProvider>(
|
||||
builder: (context, provider, __) => const ExamplePage(),
|
||||
),
|
||||
),
|
||||
theme: ThemeData.dark(),
|
||||
home: const ExampleMainPage(),
|
||||
theme: ThemeData.dark(useMaterial3: true),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +30,43 @@ class ExamplePage extends StatefulWidget {
|
||||
State<ExamplePage> createState() => _ExamplePageState();
|
||||
}
|
||||
|
||||
Widget getDrawer(BuildContext context) => Drawer(
|
||||
child: Column(
|
||||
children: [
|
||||
const DrawerHeader(child: Text('Drawer Header')),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.home),
|
||||
title: const Text('Home'),
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ExampleMainPage(),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.search),
|
||||
title: const Text('Example page'),
|
||||
onTap: () => Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => const ExampleSecondPage(),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
class ExampleMainPage extends StatelessWidget {
|
||||
const ExampleMainPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider(
|
||||
create: (_) => GymLinkProvider(),
|
||||
child: Consumer<GymLinkProvider>(
|
||||
builder: (_, value, __) => const ExamplePage(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class _ExamplePageState extends State<ExamplePage> {
|
||||
@override
|
||||
void initState() {
|
||||
@@ -46,7 +78,10 @@ class _ExamplePageState extends State<ExamplePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('GymLink Example App')),
|
||||
appBar: AppBar(
|
||||
title: const Text('GymLink Example App'),
|
||||
),
|
||||
drawer: getDrawer(context),
|
||||
body: Column(
|
||||
children: [
|
||||
const Text('test'),
|
||||
@@ -77,3 +112,20 @@ class _ExamplePageState extends State<ExamplePage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ExampleSecondPage extends StatelessWidget {
|
||||
const ExampleSecondPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('GymLink Example App'),
|
||||
),
|
||||
drawer: getDrawer(context),
|
||||
body: const Center(
|
||||
child: Text('Example page'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user