fix: font not found error log (#5449)

* fix: font not found error log

* fix: flutter analyze
This commit is contained in:
Lucas.Xu 2024-06-04 09:28:28 +08:00 committed by GitHub
parent 03e8dba5f3
commit 1e485188eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 21 deletions

View File

@ -237,8 +237,7 @@ class EditorStyleCustomizer {
try {
return getGoogleFontSafely(fontFamily, fontWeight: fontWeight);
} on Exception {
if ([defaultFontFamily, fallbackFontFamily, builtInCodeFontFamily]
.contains(fontFamily)) {
if ([defaultFontFamily, builtInCodeFontFamily].contains(fontFamily)) {
return TextStyle(fontFamily: fontFamily, fontWeight: fontWeight);
}

View File

@ -6,7 +6,6 @@ import 'package:google_fonts/google_fonts.dart';
const _defaultFontFamilies = [
defaultFontFamily,
builtInCodeFontFamily,
fallbackFontFamily,
];
// if the font family is not available, google fonts packages will throw an exception

View File

@ -41,7 +41,6 @@ class AppearanceSettingsCubit extends Cubit<AppearanceSettingsState> {
appTheme,
appearanceSettings.themeMode,
appearanceSettings.font,
appearanceSettings.monospaceFont,
appearanceSettings.layoutDirection,
appearanceSettings.textDirection,
appearanceSettings.enableRtlToolbarItems,
@ -374,7 +373,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
required AppTheme appTheme,
required ThemeMode themeMode,
required String font,
required String monospaceFont,
required LayoutDirection layoutDirection,
required AppFlowyTextDirection? textDirection,
required bool enableRtlToolbarItems,
@ -393,7 +391,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
AppTheme appTheme,
ThemeModePB themeModePB,
String font,
String monospaceFont,
LayoutDirectionPB layoutDirectionPB,
TextDirectionPB? textDirectionPB,
bool enableRtlToolbarItems,
@ -410,7 +407,6 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
return AppearanceSettingsState(
appTheme: appTheme,
font: font,
monospaceFont: monospaceFont,
layoutDirection: LayoutDirection.fromLayoutDirectionPB(layoutDirectionPB),
textDirection: AppFlowyTextDirection.fromTextDirectionPB(textDirectionPB),
enableRtlToolbarItems: enableRtlToolbarItems,
@ -435,7 +431,7 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
appTheme,
brightness,
font,
monospaceFont,
builtInCodeFontFamily,
);
}
}

View File

@ -11,9 +11,6 @@ import 'package:flutter/material.dart';
// Desktop: Based on the OS
const defaultFontFamily = '';
// the Poppins font is embedded in the app, so we can use it without GoogleFonts
// TODO(Lucas): after releasing version 0.5.6, remove it.
const fallbackFontFamily = 'Poppins';
const builtInCodeFontFamily = 'RobotoMono';
abstract class BaseAppearance {
@ -47,7 +44,7 @@ abstract class BaseAppearance {
height: lineHeight,
);
if (fontFamily == defaultFontFamily || fontFamily == fallbackFontFamily) {
if (fontFamily == defaultFontFamily) {
return textStyle;
}

View File

@ -37,7 +37,6 @@ void main() {
),
verify: (bloc) {
expect(bloc.state.font, defaultFontFamily);
expect(bloc.state.monospaceFont, 'SF Mono');
expect(bloc.state.themeMode, ThemeMode.system);
},
);

View File

@ -1,17 +1,17 @@
import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_radio_select.dart';
import 'package:flowy_infra/theme.dart';
import 'package:flutter/material.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/user/application/user_settings_service.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_radio_select.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart';
import 'package:appflowy/user/application/user_settings_service.dart';
import '../util.dart';
@ -41,7 +41,6 @@ void main() {
AppTheme.fallback,
appearanceSettings.themeMode,
appearanceSettings.font,
appearanceSettings.monospaceFont,
appearanceSettings.layoutDirection,
appearanceSettings.textDirection,
appearanceSettings.enableRtlToolbarItems,