Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: enable linter rule require_trailing_commas #1004

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ analyzer:
- example/
- packages/
- "**/*.g.dart"

linter:
rules:
- require_trailing_commas
4 changes: 4 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
- "**/*.g.dart"

linter:
rules:
- require_trailing_commas
10 changes: 10 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Generated file. Do not edit.
//

import FlutterMacOS
import Foundation


func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
}
11 changes: 11 additions & 0 deletions example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/joshua/fvm/versions/3.16.5
FLUTTER_APPLICATION_PATH=/Users/joshua/code/appainter/example
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
12 changes: 12 additions & 0 deletions example/macos/Flutter/ephemeral/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/joshua/fvm/versions/3.16.5"
export "FLUTTER_APPLICATION_PATH=/Users/joshua/code/appainter/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
12 changes: 7 additions & 5 deletions lib/abstract_text_style/cubit/abstract_text_style_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ abstract class AbstractTextStyleCubit extends Cubit<TextStyleState> {
AbstractTextStyleCubit({
required this.typeScale,
this.isBaseStyleBlack = true,
}) : super(TextStyleState(
style: isBaseStyleBlack
? kBlackTextStyles[typeScale]!
: kWhiteTextStyles[typeScale]!,
));
}) : super(
TextStyleState(
style: isBaseStyleBlack
? kBlackTextStyles[typeScale]!
: kWhiteTextStyles[typeScale]!,
),
);

final TypeScale typeScale;
final bool isBaseStyleBlack;
Expand Down
10 changes: 6 additions & 4 deletions lib/app_bar_theme/widgets/system_overlay_style_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ class _StatusBarBrightnessDropdown extends StatelessWidget {
return DropdownListTile(
title: 'Status bar brightness',
value: UtilService.enumToString(
(state.theme.systemOverlayStyle ?? _defaultSystemOverlayStyle)
.statusBarBrightness),
(state.theme.systemOverlayStyle ?? _defaultSystemOverlayStyle)
.statusBarBrightness,
),
values: UtilService.getEnumStrings(Brightness.values),
onChanged:
context.read<AppBarThemeCubit>().statusBarBrightnessChanged,
Expand All @@ -92,8 +93,9 @@ class _StatusBarIconBrightnessDropdown extends StatelessWidget {
return DropdownListTile(
title: 'Status bar icon brightness',
value: UtilService.enumToString(
(state.theme.systemOverlayStyle ?? _defaultSystemOverlayStyle)
.statusBarIconBrightness),
(state.theme.systemOverlayStyle ?? _defaultSystemOverlayStyle)
.statusBarIconBrightness,
),
values: UtilService.getEnumStrings(Brightness.values),
onChanged:
context.read<AppBarThemeCubit>().statusBarIconBrightnessChanged,
Expand Down
10 changes: 6 additions & 4 deletions lib/basic_theme/cubit/basic_theme_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class BasicThemeCubit extends Cubit<BasicThemeState> {
}

void themeReset() {
emit(state.copyWith(
seedColor: BasicThemeState.defaultSeedColor,
colorScheme: BasicThemeState.getColorScheme(state.isDark),
));
emit(
state.copyWith(
seedColor: BasicThemeState.defaultSeedColor,
colorScheme: BasicThemeState.getColorScheme(state.isDark),
),
);
}

void seedColorChanged(Color color) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BottomNavigationBarThemeEditor extends ExpansionPanelItem {
),
),
],
)
),
],
);
}
Expand Down
44 changes: 23 additions & 21 deletions lib/color_theme/cubit/color_theme_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ class ColorThemeCubit extends Cubit<ColorThemeState> {
ColorThemeCubit() : super(ColorThemeState());

void themeChanged(ThemeData theme) {
emit(state.copyWith(
colorScheme: theme.colorScheme,
primaryColor: theme.primaryColor,
primaryColorLight: theme.primaryColorLight,
primaryColorDark: theme.primaryColorDark,
canvasColor: theme.canvasColor,
cardColor: theme.cardColor,
dialogBackgroundColor: theme.dialogBackgroundColor,
disabledColor: theme.disabledColor,
dividerColor: theme.dividerColor,
focusColor: theme.focusColor,
highlightColor: theme.highlightColor,
hintColor: theme.hintColor,
hoverColor: theme.hoverColor,
indicatorColor: theme.indicatorColor,
scaffoldBackgroundColor: theme.scaffoldBackgroundColor,
secondaryHeaderColor: theme.secondaryHeaderColor,
shadowColor: theme.shadowColor,
splashColor: theme.splashColor,
unselectedWidgetColor: theme.unselectedWidgetColor,
));
emit(
state.copyWith(
colorScheme: theme.colorScheme,
primaryColor: theme.primaryColor,
primaryColorLight: theme.primaryColorLight,
primaryColorDark: theme.primaryColorDark,
canvasColor: theme.canvasColor,
cardColor: theme.cardColor,
dialogBackgroundColor: theme.dialogBackgroundColor,
disabledColor: theme.disabledColor,
dividerColor: theme.dividerColor,
focusColor: theme.focusColor,
highlightColor: theme.highlightColor,
hintColor: theme.hintColor,
hoverColor: theme.hoverColor,
indicatorColor: theme.indicatorColor,
scaffoldBackgroundColor: theme.scaffoldBackgroundColor,
secondaryHeaderColor: theme.secondaryHeaderColor,
shadowColor: theme.shadowColor,
splashColor: theme.splashColor,
unselectedWidgetColor: theme.unselectedWidgetColor,
),
);
}

void primaryColorChanged(Color color, bool isDark) {
Expand Down
4 changes: 2 additions & 2 deletions lib/home/views/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class HomePageState extends State<HomePage> {
Text(
'Appainter currently supports Flutter SDK: $_sdkVersion',
style: Theme.of(context).textTheme.titleSmall,
)
),
],
),
);
Expand Down Expand Up @@ -149,7 +149,7 @@ class _EditorPreview extends StatelessWidget {
child: const ThemePreview(),
),
),
)
),
],
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/home/widgets/export_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class ExportButton extends StatelessWidget {
style: context.read<ElevatedButtonThemeCubit>().state.style,
);
final outlinedButtonTheme = OutlinedButtonThemeData(
style: context.read<OutlinedButtonThemeCubit>().state.style);
style: context.read<OutlinedButtonThemeCubit>().state.style,
);
final textButtonTheme = TextButtonThemeData(
style: context.read<TextButtonThemeCubit>().state.style,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class _BorderRadiusTextFieldState extends State<_BorderRadiusTextField> {
current.theme.border?.isOutline != true;
},
listener: (context, state) => _controller.clear(),
)
),
],
child: BlocBuilder<InputDecorationThemeCubit, InputDecorationThemeState>(
key: const Key('inputDecorationThemeEditor_borderRadiusTextField'),
Expand Down
12 changes: 7 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ Future<void> _runApp() async {
analyticsRepo = EmptyAnalyticsRepository();
}

runApp(MyApp(
homeRepo: HomeRepository(),
fontRepo: FontRepository(),
analyticsRepo: analyticsRepo,
));
runApp(
MyApp(
homeRepo: HomeRepository(),
fontRepo: FontRepository(),
analyticsRepo: analyticsRepo,
),
);
}
2 changes: 1 addition & 1 deletion lib/switch_theme/view/switch_theme_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SwitchThemeEditor extends ExpansionPanelItem {
SideBySide(
left: _MaterialTapTargetSizeDropdown(),
right: _SplashRadiusTextField(),
)
),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/theme_preview/views/buttons_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class _IconButtons extends StatelessWidget {
onPressed: null,
),
],
)
),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/list_tiles/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MyListTile extends StatelessWidget {
],
),
),
if (trailing != null) trailing!
if (trailing != null) trailing!,
],
);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/annotations/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
- "**/*.g.dart"

linter:
rules:
- require_trailing_commas
4 changes: 4 additions & 0 deletions packages/builder/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
- "**/*.g.dart"

linter:
rules:
- require_trailing_commas
14 changes: 8 additions & 6 deletions packages/builder/lib/src/theme_docs_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ThemeDocsGenerator extends GeneratorForAnnotation<ThemeDocs> {
'double',
'bool',
'IconThemeData',
'TextStyle'
'TextStyle',
};

@override
Expand Down Expand Up @@ -52,11 +52,13 @@ class ThemeDocsGenerator extends GeneratorForAnnotation<ThemeDocs> {
className: 'ThemeData',
propertyTypes: propertyTypes,
))
..addAll(await _getThemeProperties(
className: 'ColorScheme',
propertyTypes: propertyTypes,
targetPropertyName: 'secondary',
));
..addAll(
await _getThemeProperties(
className: 'ColorScheme',
propertyTypes: propertyTypes,
targetPropertyName: 'secondary',
),
);
} else if (className == 'AppBarTheme') {
props = await _getThemeProperties(
className: apiClassName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void main() {
expect: () => [
TextStyleState(
style: isDark ? cubit.whiteTextStyle : cubit.blackTextStyle,
)
),
],
);
}
Expand Down
4 changes: 2 additions & 2 deletions test/basic_theme/basic_theme_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void main() {
onSecondary: color,
secondaryContainer: color,
onSecondaryContainer: color,
)
),
],
);

Expand Down Expand Up @@ -219,7 +219,7 @@ void main() {
onTertiary: color,
tertiaryContainer: color,
onTertiaryContainer: color,
)
),
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void main() {

for (var key in [
'bottomNavigationBarThemeEditor_labelTextStyleCard',
'bottomNavigationBarThemeEditor_unselectedLabelTextStyleCard'
'bottomNavigationBarThemeEditor_unselectedLabelTextStyleCard',
]) {
expect(find.byKey(Key(key)), findsOneWidget);
}
Expand Down
4 changes: 2 additions & 2 deletions test/checkbox_theme/checkbox_theme_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void main() {
final props = {
MaterialState.pressed: color,
MaterialState.hovered: overlayHoveredColor,
MaterialState.focused: overlayFocusedColor
MaterialState.focused: overlayFocusedColor,
};

verifyMaterialPropertyByMap(cubit.state.theme.overlayColor!, props);
Expand All @@ -140,7 +140,7 @@ void main() {
final props = {
MaterialState.pressed: overlayPressedColor,
MaterialState.hovered: color,
MaterialState.focused: overlayFocusedColor
MaterialState.focused: overlayFocusedColor,
};

verifyMaterialPropertyByMap(cubit.state.theme.overlayColor!, props);
Expand Down
8 changes: 4 additions & 4 deletions test/color_theme/color_theme_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
shadowColor: theme.shadowColor,
splashColor: theme.splashColor,
unselectedWidgetColor: theme.unselectedWidgetColor,
)
),
],
);

Expand Down Expand Up @@ -80,7 +80,7 @@ void main() {
primaryColorDark: swatch[700],
indicatorColor: color,
secondaryHeaderColor: swatch[50],
)
),
];
},
);
Expand All @@ -103,7 +103,7 @@ void main() {
secondary: color,
onSecondary: onColor,
),
)
),
];
},
);
Expand Down Expand Up @@ -181,7 +181,7 @@ void main() {
colorScheme: colorThemeCubit.state.colorScheme.copyWith(
error: color,
),
)
),
],
);

Expand Down
4 changes: 3 additions & 1 deletion test/home/views/home_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ void main() {
await tester.pumpAndSettle();

expect(
find.byKey(const Key('usageButton_usageFallback')), findsOneWidget);
find.byKey(const Key('usageButton_usageFallback')),
findsOneWidget,
);
},
);

Expand Down
Loading