mmvergara / supadart

Typesafe queries in Supabase Flutter! Generate Flutter / Dart 🎯 classes from your Supabase schema.
https://supadart.vercel.app
MIT License
43 stars 5 forks source link

Request feature: automatic add `import 'supadart_abstract_class.dart';` #32

Closed bookshiyi closed 3 months ago

bookshiyi commented 3 months ago

Hi, @mmvergara

Thanks for your excellent project, automatically generate dart code from supabase is so cool.

But I encountered a little confusion in the process of use. Every time the automatic creation is completed, I need to manually add the line import 'supadart_abstract_class.dart'; to each model file at --seperate mode.

Could this be automated? Or do you have other considerations?

BR

mmvergara commented 3 months ago

Hi, Thanks for the feedback. I actually forgot to do this part, i was too focused on type conversions/integrity, will work on it asap. Thanks again

The problem is that in --seperate you can specify path on where the generated models are going therefore the import statement changes depends on the package or app name and the path

Additionally: I'd like to also know if there is a particular reason you prefer the --seperate option over the 1 file model?

mmvergara commented 3 months ago

@bookshiyi updated the cli to 1.3.4 please let me know if you're still having troubles.

bookshiyi commented 3 months ago

@bookshiyi updated the cli to 1.3.4 please let me know if you're still having troubles.

Wow, thank you for fixing this problem so quickly. I just tested it, and found that I don't need to manually add import every time, so convenient! The results generated now are as follows:

import 'package:{PROJECT}/models//supadart_abstract_class.dart';
// You have to manually import SupadartClass if you are using seperated files option

There seem to be some minor problems that don't hurt the elegance: There is two / between models and supadart_abstract_class.dart; In addition, the comment maybe can be deleted.

import 'supadart_abstract_class.dart';

Could we change the generation result to this, how do you think about it?


Hi, Thanks for the feedback. I actually forgot to do this part, i was too focused on type conversions/integrity, will work on it asap. Thanks again

The problem is that in --seperate you can specify path on where the generated models are going therefore the import statement changes depends on the package or app name and the path

Additionally: I'd like to also know if there is a particular reason you prefer the --seperate option over the 1 file model?

modela.dart
modelb.dart
client_extension.dart
supadart_abstract_class.dart

Is it not applicable if these files are placed in lib/models? The directory of the model files of my project has always been lib/models.

There is no doubt that I like the --separate mode, because I usually want to keep the model file concise, to maintain the style that one file only includes one class. Perhaps from the perspective of users, the developers who found the tool supadart, it is likely that they are facing multiple tables, and each table has multiple columns. In the face of such a complex structure, --separate mode may be a better choice. On the contrary, for those projects with low number and complexity of tables, models only need to be placed in one file, but these projects maybe do not need supadart to automatic generation, right?

mmvergara commented 3 months ago

import 'supadart_abstract_class.dart'; Could we change the generation result to this, how do you think about it?

sorry i was late to realized that you can just do import 'supadart_abstract_class.dart'; if they files are in the same folder 💀. will fix it. Thank you again.

should be fixed by now https://github.com/mmvergara/supadart/pull/34 cli 1.3.5

bookshiyi commented 3 months ago

awesome! Thanks for your generous