Themes
#425
Replies: 1 comment 2 replies
-
You can set theme via configuring your application's We currently doesn't provide a way to automatically switch between the light and dark modes of a theme. This can be managed by wrapping import 'package:flutter/material.dart';
class Application extends StatefulWidget {
const Application({super.key});
@override
State<Application> createState() => _ApplicationState();
}
class _ApplicationState extends State<Application> {
bool _isDarkMode = false;
void _toggleThemeMode() {
setState(() {
_isDarkMode = !_isDarkMode;
});
}
@override
Widget build(BuildContext context) => MaterialApp(
builder: (context, child) => FTheme(
data: _isDarkMode ? FThemes.zinc.dark : FThemes.zinc.light,
child: child!,
),
home: FScaffold(
// Assuming FScaffold accepts similar parameters to Scaffold
appBar: AppBar(
title: const Text('My Application'),
actions: [
IconButton(
icon: Icon(_isDarkMode ? Icons.light_mode : Icons.dark_mode),
onPressed: _toggleThemeMode,
tooltip: 'Toggle theme',
),
],
),
body: const Center(
child: Text('Content goes here'),
),
),
);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, Thanks for the great package.
I am a beginner and I am confused about;
How can one set default thememode as we do with material 3 and also themes(dark,light).
Beta Was this translation helpful? Give feedback.
All reactions