// Flutter imports: import 'package:flutter/material.dart'; /// /// Расширение для темы всего приложения /// Для [Theme] /// /// Используется для хранения общих типов цветов /// class AppThemeExtension extends ThemeExtension { AppThemeExtension({ required this.background, required this.textColor, required this.appBarBackground, }); AppThemeExtension.light() : background = Colors.white, textColor = Colors.black, appBarBackground = Colors.indigo; AppThemeExtension.dark() : background = Colors.black, textColor = Colors.white, appBarBackground = Colors.lightGreen; /// Цвет фона final Color background; /// Цвет текста final Color textColor; /// Цвет фона [AppBar] final Color appBarBackground; @override ThemeExtension copyWith({ Color? background, Color? textColor, Color? appBarBackground, }) { return AppThemeExtension( background: background ?? this.background, textColor: textColor ?? this.textColor, appBarBackground: appBarBackground ?? this.appBarBackground, ); } @override ThemeExtension lerp( ThemeExtension? other, double t, ) { if (other is! AppThemeExtension) { return this; } return AppThemeExtension( background: Color.lerp(background, other.background, t)!, textColor: Color.lerp(textColor, other.textColor, t)!, appBarBackground: Color.lerp(appBarBackground, other.appBarBackground, t)!, ); } }