Created
November 3, 2022 09:57
-
-
Save hawkkiller/56fb9cc465a49155f178baee680a08e3 to your computer and use it in GitHub Desktop.
Themegen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:themegen_annotation/themegen_annotation.dart'; | |
part 'example.g.dart'; | |
@ThemeGen( | |
extensions: { | |
_$AppColorsLight, | |
_$AppFontStylesLight, | |
}, | |
) | |
abstract class _$AppThemeLight {} | |
@ThemeGen( | |
extensions: { | |
_$AppColorsDark, | |
_$AppFontStylesDark, | |
}, | |
) | |
class _$AppThemeDark {} | |
class _$AppColorsLight { | |
static const Color primary = Color(0xFF000000); | |
static const Color secondary = Color(0xFF000000); | |
} | |
class _$AppColorsDark { | |
static const Color primary = Color(0xFF000000); | |
static const Color secondary = Color(0xFF000000); | |
} | |
class _$AppFontStylesLight { | |
static TextStyle h1(AppColors colors, AppColors colors2) => TextStyle( | |
color: colors.primary, | |
); | |
} | |
class _$AppFontStylesDark { | |
static TextStyle h1(AppColors colors, AppColors colors2) => TextStyle( | |
color: colors.primary, | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GENERATED CODE - DO NOT MODIFY BY HAND | |
part of 'example.dart'; | |
// ************************************************************************** | |
// ThemeGenerator | |
// ************************************************************************** | |
class AppColors extends ThemeExtension<AppColors> { | |
AppColors({ | |
required this.primary, | |
required this.secondary, | |
}); | |
AppColors._lerp({ | |
required Color primary, | |
required Color secondary, | |
required double t, | |
required AppColors other, | |
}) : primary = Color.lerp(primary, other.primary, t)!, | |
secondary = Color.lerp(secondary, other.secondary, t)!; | |
final Color primary; | |
final Color secondary; | |
@factory | |
static AppColors light({ | |
Color? primary, | |
Color? secondary, | |
}) => | |
AppColors( | |
primary: primary ?? _$AppColorsLight.primary, | |
secondary: secondary ?? _$AppColorsLight.secondary, | |
); | |
@factory | |
static AppColors dark({ | |
Color? primary, | |
Color? secondary, | |
}) => | |
AppColors( | |
primary: primary ?? _$AppColorsDark.primary, | |
secondary: secondary ?? _$AppColorsDark.secondary, | |
); | |
@override | |
AppColors lerp( | |
ThemeExtension<AppColors>? other, | |
double t, | |
) { | |
if (other is! AppColors) { | |
return this; | |
} | |
return AppColors._lerp( | |
other: other, | |
t: t, | |
primary: primary, | |
secondary: secondary, | |
); | |
} | |
@override | |
AppColors copyWith({ | |
Color? primary, | |
Color? secondary, | |
}) { | |
return AppColors( | |
primary: primary ?? this.primary, | |
secondary: secondary ?? this.secondary, | |
); | |
} | |
} | |
class AppFontStyles extends ThemeExtension<AppFontStyles> { | |
AppFontStyles({ | |
required TextStyle Function(AppColors, AppColors) h1, | |
required AppColors appColors, | |
}) : h1 = h1(appColors, appColors), | |
_$h1 = h1, | |
_$appColors = appColors; | |
AppFontStyles._lerp({ | |
required TextStyle Function(AppColors, AppColors) h1, | |
required AppColors appColors, | |
required double t, | |
required AppFontStyles other, | |
}) : h1 = TextStyle.lerp( | |
h1(appColors, appColors), other._$h1(appColors, appColors), t)!, | |
_$h1 = h1, | |
_$appColors = appColors; | |
final TextStyle h1; | |
final TextStyle Function(AppColors, AppColors) _$h1; | |
final AppColors _$appColors; | |
@factory | |
static AppFontStyles light({ | |
TextStyle Function(AppColors, AppColors)? h1, | |
required AppColors appColors, | |
}) => | |
AppFontStyles( | |
h1: h1 ?? _$AppFontStylesLight.h1, | |
appColors: appColors, | |
); | |
@factory | |
static AppFontStyles dark({ | |
TextStyle Function(AppColors, AppColors)? h1, | |
required AppColors appColors, | |
}) => | |
AppFontStyles( | |
h1: h1 ?? _$AppFontStylesDark.h1, | |
appColors: appColors, | |
); | |
@override | |
AppFontStyles lerp( | |
ThemeExtension<AppFontStyles>? other, | |
double t, | |
) { | |
if (other is! AppFontStyles) { | |
return this; | |
} | |
return AppFontStyles._lerp( | |
other: other, | |
t: t, | |
h1: _$h1, | |
appColors: _$appColors, | |
); | |
} | |
@override | |
AppFontStyles copyWith({ | |
TextStyle Function(AppColors, AppColors)? h1, | |
AppColors? appColors, | |
}) { | |
return AppFontStyles(h1: h1 ?? _$h1, appColors: appColors ?? _$appColors); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment