Skip to content

Commit

Permalink
♻️ update example to use material 3
Browse files Browse the repository at this point in the history
  • Loading branch information
BirjuVachhani committed Oct 3, 2023
1 parent 0df6f51 commit d933227
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions example/lib/material_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class MaterialExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AdaptiveTheme(
light: ThemeData.light(),
dark: ThemeData.dark(),
light: ThemeData.light(
useMaterial3: true,
),
dark: ThemeData.dark(
useMaterial3: true,
),
debugShowFloatingThemeButton: true,
initial: savedThemeMode ?? AdaptiveThemeMode.light,
builder: (theme, darkTheme) => MaterialApp(
Expand Down Expand Up @@ -78,7 +82,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
const Spacer(),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).toggleThemeMode(),
style: ElevatedButton.styleFrom(
visualDensity:
Expand All @@ -87,7 +91,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('Toggle Theme Mode'),
),
const SizedBox(height: 8),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).setDark(),
style: ElevatedButton.styleFrom(
visualDensity:
Expand All @@ -96,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('Set Dark'),
),
const SizedBox(height: 8),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).setLight(),
style: ElevatedButton.styleFrom(
visualDensity:
Expand All @@ -105,7 +109,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('set Light'),
),
const SizedBox(height: 8),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).setSystem(),
style: ElevatedButton.styleFrom(
visualDensity:
Expand All @@ -114,15 +118,17 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('Set System Default'),
),
const SizedBox(height: 8),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).setTheme(
light: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.pink,
brightness: Brightness.light,
primarySwatch: Colors.pink,
),
dark: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
primarySwatch: Colors.pink,
colorSchemeSeed: Colors.pink,
),
),
style: ElevatedButton.styleFrom(
Expand All @@ -132,7 +138,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Text('Set Custom Theme'),
),
const SizedBox(height: 8),
ElevatedButton(
FilledButton(
onPressed: () => AdaptiveTheme.of(context).reset(),
style: ElevatedButton.styleFrom(
visualDensity:
Expand Down

0 comments on commit d933227

Please sign in to comment.