Fix providers
This commit is contained in:
@@ -17,13 +17,8 @@ class MyExampleApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'GymLink Example App',
|
title: 'GymLink Example App',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: ChangeNotifierProvider(
|
home: const ExampleMainPage(),
|
||||||
create: (_) => GymLinkProvider(),
|
theme: ThemeData.dark(useMaterial3: true),
|
||||||
child: Consumer<GymLinkProvider>(
|
|
||||||
builder: (context, provider, __) => const ExamplePage(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
theme: ThemeData.dark(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,6 +30,43 @@ class ExamplePage extends StatefulWidget {
|
|||||||
State<ExamplePage> createState() => _ExamplePageState();
|
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> {
|
class _ExamplePageState extends State<ExamplePage> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -46,7 +78,10 @@ class _ExamplePageState extends State<ExamplePage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('GymLink Example App')),
|
appBar: AppBar(
|
||||||
|
title: const Text('GymLink Example App'),
|
||||||
|
),
|
||||||
|
drawer: getDrawer(context),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
const Text('test'),
|
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