Home > other >  How to create Private directory like private classes in Flutter
How to create Private directory like private classes in Flutter

Time:11-23

Consider the below folder structure. I want to restrict the access to _child directory, like only the parnet of _child should have access to it. another_parnent or another directory should not access it.

_ another_parnet
- parent/
  - parnet1.dart
  - parent2.dart
  - parent3.dart
  - _child/
    - child1.dart
    - child2.dart
    - child3.dart

Is it possible to do in Flutter?

Tried googling and going through flutter documentation.

CodePudding user response:

No it is not possible. The only privacy you can achieve is within files and classes using the _ notation.

By using the part keyword in the "child files" you could have a folder structure between the parent and child directories as you've written it with all classes in the children marked with _ and thereby only allowing parent to use them. I.e. not allowing another_parent to use them. It would essentially be like having it all in one file. But in this scenario you need to have one top parent file that all subdirectory files (and other parent files in your example) are a part of.

  • Related