@@ -27,6 +27,8 @@ import 'switch_theme.dart';
2727import 'theme.dart' ;
2828import 'theme_data.dart' ;
2929
30+ part 'generated/switch_defaults_m3.g.dart' ;
31+
3032// Examples can assume:
3133// bool _giveVerse = true;
3234// late StateSetter setState;
@@ -2140,234 +2142,3 @@ class _SwitchDefaultsM2 extends SwitchThemeData {
21402142 @override
21412143 EdgeInsetsGeometry ? get padding => EdgeInsets .zero;
21422144}
2143-
2144- // BEGIN GENERATED TOKEN PROPERTIES - Switch
2145-
2146- // Do not edit by hand. The code between the "BEGIN GENERATED" and
2147- // "END GENERATED" comments are generated from data in the Material
2148- // Design token database by the script:
2149- // dev/tools/gen_defaults/bin/gen_defaults.dart.
2150-
2151- // dart format off
2152- class _SwitchDefaultsM3 extends SwitchThemeData {
2153- _SwitchDefaultsM3 (this .context);
2154-
2155- final BuildContext context;
2156- late final ColorScheme _colors = Theme .of (context).colorScheme;
2157-
2158- @override
2159- WidgetStateProperty <Color > get thumbColor {
2160- return WidgetStateProperty .resolveWith ((Set <WidgetState > states) {
2161- if (states.contains (WidgetState .disabled)) {
2162- if (states.contains (WidgetState .selected)) {
2163- return _colors.surface.withOpacity (1.0 );
2164- }
2165- return _colors.onSurface.withOpacity (0.38 );
2166- }
2167- if (states.contains (WidgetState .selected)) {
2168- if (states.contains (WidgetState .pressed)) {
2169- return _colors.primaryContainer;
2170- }
2171- if (states.contains (WidgetState .hovered)) {
2172- return _colors.primaryContainer;
2173- }
2174- if (states.contains (WidgetState .focused)) {
2175- return _colors.primaryContainer;
2176- }
2177- return _colors.onPrimary;
2178- }
2179- if (states.contains (WidgetState .pressed)) {
2180- return _colors.onSurfaceVariant;
2181- }
2182- if (states.contains (WidgetState .hovered)) {
2183- return _colors.onSurfaceVariant;
2184- }
2185- if (states.contains (WidgetState .focused)) {
2186- return _colors.onSurfaceVariant;
2187- }
2188- return _colors.outline;
2189- });
2190- }
2191-
2192- @override
2193- WidgetStateProperty <Color > get trackColor {
2194- return WidgetStateProperty .resolveWith ((Set <WidgetState > states) {
2195- if (states.contains (WidgetState .disabled)) {
2196- if (states.contains (WidgetState .selected)) {
2197- return _colors.onSurface.withOpacity (0.12 );
2198- }
2199- return _colors.surfaceContainerHighest.withOpacity (0.12 );
2200- }
2201- if (states.contains (WidgetState .selected)) {
2202- if (states.contains (WidgetState .pressed)) {
2203- return _colors.primary;
2204- }
2205- if (states.contains (WidgetState .hovered)) {
2206- return _colors.primary;
2207- }
2208- if (states.contains (WidgetState .focused)) {
2209- return _colors.primary;
2210- }
2211- return _colors.primary;
2212- }
2213- if (states.contains (WidgetState .pressed)) {
2214- return _colors.surfaceContainerHighest;
2215- }
2216- if (states.contains (WidgetState .hovered)) {
2217- return _colors.surfaceContainerHighest;
2218- }
2219- if (states.contains (WidgetState .focused)) {
2220- return _colors.surfaceContainerHighest;
2221- }
2222- return _colors.surfaceContainerHighest;
2223- });
2224- }
2225-
2226- @override
2227- WidgetStateProperty <Color ?> get trackOutlineColor {
2228- return WidgetStateProperty .resolveWith ((Set <WidgetState > states) {
2229- if (states.contains (WidgetState .selected)) {
2230- return Colors .transparent;
2231- }
2232- if (states.contains (WidgetState .disabled)) {
2233- return _colors.onSurface.withOpacity (0.12 );
2234- }
2235- return _colors.outline;
2236- });
2237- }
2238-
2239- @override
2240- WidgetStateProperty <Color ?> get overlayColor {
2241- return WidgetStateProperty .resolveWith ((Set <WidgetState > states) {
2242- if (states.contains (WidgetState .selected)) {
2243- if (states.contains (WidgetState .pressed)) {
2244- return _colors.primary.withOpacity (0.1 );
2245- }
2246- if (states.contains (WidgetState .hovered)) {
2247- return _colors.primary.withOpacity (0.08 );
2248- }
2249- if (states.contains (WidgetState .focused)) {
2250- return _colors.primary.withOpacity (0.1 );
2251- }
2252- return null ;
2253- }
2254- if (states.contains (WidgetState .pressed)) {
2255- return _colors.onSurface.withOpacity (0.1 );
2256- }
2257- if (states.contains (WidgetState .hovered)) {
2258- return _colors.onSurface.withOpacity (0.08 );
2259- }
2260- if (states.contains (WidgetState .focused)) {
2261- return _colors.onSurface.withOpacity (0.1 );
2262- }
2263- return null ;
2264- });
2265- }
2266-
2267- @override
2268- WidgetStateProperty <MouseCursor > get mouseCursor {
2269- return WidgetStateProperty .resolveWith ((Set <WidgetState > states)
2270- => WidgetStateMouseCursor .clickable.resolve (states));
2271- }
2272-
2273- @override
2274- MaterialStatePropertyAll <double > get trackOutlineWidth => const MaterialStatePropertyAll <double >(2.0 );
2275-
2276- @override
2277- double get splashRadius => 40.0 / 2 ;
2278-
2279- @override
2280- EdgeInsetsGeometry ? get padding => const EdgeInsets .symmetric (horizontal: 4 );
2281- }
2282-
2283- class _SwitchConfigM3 with _SwitchConfig {
2284- _SwitchConfigM3 (this .context)
2285- : _colors = Theme .of (context).colorScheme;
2286-
2287- BuildContext context;
2288- final ColorScheme _colors;
2289-
2290- static const double iconSize = 16.0 ;
2291-
2292- @override
2293- double get activeThumbRadius => 24.0 / 2 ;
2294-
2295- @override
2296- WidgetStateProperty <Color > get iconColor {
2297- return WidgetStateProperty .resolveWith ((Set <WidgetState > states) {
2298- if (states.contains (WidgetState .disabled)) {
2299- if (states.contains (WidgetState .selected)) {
2300- return _colors.onSurface.withOpacity (0.38 );
2301- }
2302- return _colors.surfaceContainerHighest.withOpacity (0.38 );
2303- }
2304- if (states.contains (WidgetState .selected)) {
2305- if (states.contains (WidgetState .pressed)) {
2306- return _colors.onPrimaryContainer;
2307- }
2308- if (states.contains (WidgetState .hovered)) {
2309- return _colors.onPrimaryContainer;
2310- }
2311- if (states.contains (WidgetState .focused)) {
2312- return _colors.onPrimaryContainer;
2313- }
2314- return _colors.onPrimaryContainer;
2315- }
2316- if (states.contains (WidgetState .pressed)) {
2317- return _colors.surfaceContainerHighest;
2318- }
2319- if (states.contains (WidgetState .hovered)) {
2320- return _colors.surfaceContainerHighest;
2321- }
2322- if (states.contains (WidgetState .focused)) {
2323- return _colors.surfaceContainerHighest;
2324- }
2325- return _colors.surfaceContainerHighest;
2326- });
2327- }
2328-
2329- @override
2330- double get inactiveThumbRadius => 16.0 / 2 ;
2331-
2332- @override
2333- double get pressedThumbRadius => 28.0 / 2 ;
2334-
2335- @override
2336- double get switchHeight => switchMinSize.height + 8.0 ;
2337-
2338- @override
2339- double get switchHeightCollapsed => switchMinSize.height;
2340-
2341- @override
2342- double get switchWidth => 52.0 ;
2343-
2344- @override
2345- double get thumbRadiusWithIcon => 24.0 / 2 ;
2346-
2347- @override
2348- List <BoxShadow >? get thumbShadow => kElevationToShadow[0 ];
2349-
2350- @override
2351- double get trackHeight => 32.0 ;
2352-
2353- @override
2354- double get trackWidth => 52.0 ;
2355-
2356- // The thumb size at the middle of the track. Hand coded default based on the animation specs.
2357- @override
2358- Size get transitionalThumbSize => const Size (34 , 22 );
2359-
2360- // Hand coded default based on the animation specs.
2361- @override
2362- int get toggleDuration => 300 ;
2363-
2364- // Hand coded default based on the animation specs.
2365- @override
2366- double ? get thumbOffset => null ;
2367-
2368- @override
2369- Size get switchMinSize => const Size (kMinInteractiveDimension, kMinInteractiveDimension - 8.0 );
2370- }
2371- // dart format on
2372-
2373- // END GENERATED TOKEN PROPERTIES - Switch
0 commit comments