felangel / bloc

A predictable state management library that helps implement the BLoC design pattern

Home Page:https://bloclibrary.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fix: vscode formatter not working correctly on generated files

lrsvmb opened this issue · comments

Description
When generating files with the vscode bloc extension, the vscode formatter (especially when using format on save) does not work correctly. The dart format . command formats them differently.

Steps To Reproduce

  1. Generate cubit or bloc using the context menu
  2. Use the format-on-save functionality
  3. Run dart format .
  4. See error

Expected Behavior
The file should be formatted the same way as all other normally created files

File after Formatting

part of 'theme_cubit.dart';


@immutable

sealed class ThemeState {}


final class ThemeInitial extends ThemeState {}


final class ThemeChanged extends ThemeState {}


File how it should look like

part of 'theme_cubit.dart';

@immutable
sealed class ThemeState {}

final class ThemeInitial extends ThemeState {}

final class ThemeChanged extends ThemeState {}

Is that a mistake on my end? All other files format correctly.

Hi @lrsvmb 👋
Thanks for opening an issue!

I'm not able to reproduce. I'm using v6.6.5 of the vscode extension and the following steps:

  1. Right click -> Bloc: New Cubit
  2. Type theme
  3. Press Enter

Generates:

part of 'theme_cubit.dart';

@immutable
sealed class ThemeState {}

final class ThemeInitial extends ThemeState {}

Are you using the latest version or are you following slightly different steps? Thanks!

I am using the latest version (v6.6.5) of the extension. The problem is not the generation process, but rather a formatting issue. When I generate the Cubit, the formatting is fine. When I then use the formatting feature provided by the dart(flutter) vscode extension, the formatting changes and does not comply with darts formatting rules anymore.

This only happens when using the formatting tool in these generated files, all other files work properly. Am I using something wrong? Is this even an issue of this extension or should I file an issue on dart's side?

That sounds like an issue with the other extension you have that's formatting the files. I'm closing this for now since I don't think there's anything to do in the bloc vscode extension, thanks!