-1

I created a flutter package and in there I added business logic.

I imported that package into my client project, and I am able to access the files and method. Upto this going well.

Now the issue is that from the client project, I am able to edit/modify dart files from packages. It should not happen. This way anyone can edit/remove business logic from flutter package.

How I can prevent the dart file from being modified?

Nikita Patil
  • 674
  • 1
  • 7
  • 17
  • So, if I well understand, what you want to say is that you want to have access in other people packages but deny other people to see your package?? In flutter (as it is an open project)?? Hmmmm: https://media1.giphy.com/media/10UHehEC098kAE/giphy.gif?cid=ecf05e47hefb48h5b1abzfl0tl5qzeu64iznl0kbc2a5x7r4&rid=giphy.gif&ct=g – G3nt_M3caj Apr 20 '23 at 09:42
  • Could you show an example? – lsaudon Apr 20 '23 at 09:42
  • @G3nt_M3caj you are correct. I am editing my question in few minutes, I will more description with some code/files. – Nikita Patil Apr 20 '23 at 09:44
  • packages are not compiled/closed code but are open code that helps you to make your app without having to develop everything from scratch. And as Flutter is an open project somewhere flutter team say that about packages: **The pub.dev site lists many packages—developed by Google engineers and generous members of the Flutter and Dart community— that you can use in your app.** – G3nt_M3caj Apr 20 '23 at 09:51
  • So, packages are not compiled code used as libraries (like DLL's of .NET or .jar of Java) but are open code that you can use, modify (as your case), improve and share for other people (if you want). – G3nt_M3caj Apr 20 '23 at 09:53
  • @G3nt_M3caj okay, then according to you then there is no other option, files from packages are open only? is this final? – Nikita Patil Apr 20 '23 at 10:02
  • YES all package files remains as .dart extension and that mean ARE NOT COMPILED, is open code you can use every where. Downloaded/imported package are all in FLUTTER_PATH\.pub-cache\hosted\pub.dartlang.org. inside of it you can see and modify what you want. – G3nt_M3caj Apr 20 '23 at 10:06
  • @NikitaPatil y're welcome!! – G3nt_M3caj Apr 20 '23 at 10:21
  • Your IDE can be set to warn if editing files outside your project. Perhaps you don't have that option set. – Randal Schwartz Apr 20 '23 at 15:39

1 Answers1

-2

Not sure if I understand it correctly. But if you are able to edit it it means you are using a local package. Meaning in your pubspec.yaml file you probably have the path written to it like

your_package:
  path: ../path/to/package

Once it's published to pub.dev you won't be putting the path there anymore but a version like

your_package: 1.0.0

Packages added like this you won't be able to edit.

Ivo
  • 18,659
  • 2
  • 23
  • 35
  • My packages are not published to pub.dev. Its private and used local usage purpose. – Nikita Patil Apr 20 '23 at 10:00
  • "Packages added like this you won't be able to edit." you are able to edit every package and this is NOT TRUE. Take a look in my comments in OP question then you can se you can modify every package. Even Intellij/Android Studio allows to navigate on downloaded/imported packages (External Libraries) as well makes changes. But, once you recall "pub get" after your changes these are overwritten by originals. – G3nt_M3caj Apr 20 '23 at 10:19
  • @G3nt_M3caj true – Ivo Apr 20 '23 at 10:32
  • @Ivo helping each other, as well the community, is a DEV DUTY. Y're welcome!! – G3nt_M3caj Apr 20 '23 at 10:37