-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy paththeming_custom.dart
71 lines (66 loc) · 2.21 KB
/
theming_custom.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pull_down_button/pull_down_button.dart';
import 'example_scaffold.dart';
/// Custom theme created from [CupertinoColors.systemBlue].
///
/// [PullDownButtonTheme] parameters are assigned based on Material 3 colors for
/// [PopupMenuButton].
@immutable
class ThemingCustom extends StatelessWidget {
const ThemingCustom({super.key});
@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
final colorScheme = ColorScheme.fromSeed(
seedColor: CupertinoColors.systemBlue.resolveFrom(context),
brightness: themeData.brightness,
);
// For the sake of simplicity, define global theme override.
return Theme(
data: themeData.copyWith(
extensions: [
PullDownButtonTheme(
routeTheme: PullDownMenuRouteTheme(
backgroundColor: ElevationOverlay.applySurfaceTint(
colorScheme.surface,
colorScheme.surfaceTint,
2,
),
),
dividerTheme: PullDownMenuDividerTheme(
dividerColor: colorScheme.outlineVariant,
largeDividerColor: colorScheme.surfaceContainerHighest,
),
itemTheme: PullDownMenuItemTheme(
destructiveColor: colorScheme.error,
textStyle: TextStyle(
fontWeight: FontWeight.w500,
color: colorScheme.onSurface,
),
iconActionTextStyle: TextStyle(
fontWeight: FontWeight.w500,
color: colorScheme.onSurface,
),
onHoverBackgroundColor: colorScheme.primary,
onHoverTextColor: colorScheme.onPrimary,
onPressedBackgroundColor: colorScheme.surfaceContainerHighest,
),
),
],
),
child: CupertinoPageScaffold(
navigationBar: ExampleScaffoldNavigationBar(
title: 'Custom theme',
),
child: SafeArea(
child: Center(
child: PullDownMenu(
items: ExampleScaffold.exampleItems(context),
),
),
),
),
);
}
}