Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Last active February 17, 2025 21:52
Show Gist options
  • Save MelbourneDeveloper/e5c70913bff23db5c159f3e3bfec0e6a to your computer and use it in GitHub Desktop.
Save MelbourneDeveloper/e5c70913bff23db5c159f3e3bfec0e6a to your computer and use it in GitHub Desktop.
Font Contrast Issue
import 'package:flutter/material.dart';
ThemeData getLightTheme() => ThemeData(
brightness: Brightness.light,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.light,
),
);
ThemeData getDarkTheme() => ThemeData(
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.dark,
),
);
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _themeMode = ThemeMode.light;
void _toggleThemeMode() {
setState(() {
_themeMode =
_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light;
});
}
@override
Widget build(BuildContext context) => MaterialApp(
theme: getLightTheme(),
darkTheme: getDarkTheme(),
themeMode: _themeMode,
debugShowCheckedModeBanner: false,
home: Builder(
builder:
(context) => Scaffold(
appBar: AppBar(
actions: [
IconButton(
icon: const Icon(Icons.brightness_6),
onPressed: _toggleThemeMode,
),
],
),
body: Center(
child: Text(
'Working',
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment