gmlewis / flutter-stylizer

Flutter Stylizer is a VSCode extension that organizes your Flutter classes and mixins in an opinionated and consistent manner.
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
Apache License 2.0
23 stars 3 forks source link

Support stylizing mixin files. #25

Closed longtimedeveloper closed 2 years ago

longtimedeveloper commented 2 years ago

When using flutter-stylizer, the mixin members are not sorted.

Would it be possible to sort mixin members as well?

Thank you!

Karl

gmlewis commented 2 years ago

Hi @longtimedeveloper ,

Just to make sure I understand you... I'm taking a look at: https://flutterbyexample.com/lesson/mixins

So in the provided example:

class Employee {
  void clockIn() {...}
}

mixin Medical {
   int takeTemperature {...}
}

... you are requesting that Flutter Stylizer not only organize what it finds within the Employee class but also everything it finds within the Medical mixin as well, correct?

longtimedeveloper commented 2 years ago

@gmlewis yes, that would be splendid! Thank you.

I would want it to format the mixin only when I'm in the mixin file, no requirement to format both at the same time.

Essentially the same as abstract classes.

gmlewis commented 2 years ago

To simplify the implementation, though, would it be OK to process all "class" and all "mixin" sections that it finds within a single file since the VSCode extension processes an entire file at once?

longtimedeveloper commented 2 years ago

sure if it is easier for you. But could be a little unexpected by developers since they may not have the file open and it's being formated.

gmlewis commented 2 years ago

No, the extension never formats a file unless it is explicitly requested to... so there should never be a chance of it accidentally formatting some other file. In other words, it never attempts to find other files to process.

longtimedeveloper commented 2 years ago

@gmlewis a few considerations.

When in a mixin, I'm hoping to be able to format it while it's open. Once a mixin is completed, developers would be working on files that consume the mixin. So, formatting a mixin that is completed and possibly checked in, may not be the best behavior.

If you can process the mixin separately, I think that would be best.

longtimedeveloper commented 2 years ago

@gmlewis Ah, you may have been referring to a mixin within the same file as the class.

I always place my mixins in their own file.

gmlewis commented 2 years ago

If the mixin is in a separate file, then that file needs to be explicitly processed by Flutter Stylizer... so there shouldn't be any confusion. The author of the mixin formats it, and the users of the mixin (presumably in other files) will process their files separately. Or maybe I'm just confused what you are asking?

@gmlewis Ah, you may have been referring to a mixin within the same file as the class.

I always place my mixins in their own file.

Yes, exactly... the extension will just process the file that is currently open... nothing else... but with my upcoming change, it will process everything found within the one file (both the classes and the mixins). You will need to explicitly open up your mixin file and process it separately.

Does that make sense?

longtimedeveloper commented 2 years ago

yes

gmlewis commented 2 years ago

OK, awesome... this should be pretty trivial to implement. :smile:

gmlewis commented 2 years ago

OK, @longtimedeveloper - version 0.1.6 should now be available and should work on mixins. Please let me know if you have any problems with it.

longtimedeveloper commented 2 years ago

@gmlewis testing now... Thank you!!!

longtimedeveloper commented 2 years ago

@gmlewis works perfect, thank you!!