Line data Source code
1 : import 'package:flutter/material.dart'; 2 : import 'package:widgetbook/src/providers/theme_provider.dart'; 3 : import 'package:widgetbook/src/utils/extensions.dart'; 4 : 5 : class ThemeHandle extends StatelessWidget { 6 15 : const ThemeHandle({Key? key}) : super(key: key); 7 : 8 0 : @override 9 : Widget build(BuildContext context) { 10 0 : final themeProvider = ThemeProvider.of(context)!; 11 0 : return Tooltip( 12 : message: 'Toggle theme', 13 0 : child: TextButton( 14 0 : onPressed: themeProvider.toggleTheme, 15 0 : style: TextButton.styleFrom( 16 : splashFactory: InkRipple.splashFactory, 17 : shape: 18 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)), 19 : minimumSize: Size.zero, 20 : padding: const EdgeInsets.all(12), 21 : ), 22 0 : child: Icon( 23 : Icons.dark_mode, 24 0 : color: themeProvider.state == ThemeMode.light 25 0 : ? context.theme.hintColor 26 0 : : context.colorScheme.primary, 27 : ), 28 : ), 29 : ); 30 : } 31 : }