Flutter Folder Structure and Packages

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • Understanding the basics of folder structure and packages is an important topic that not many covers. Here we will learn different types of folder structure as well as how we can use dart packages to our own advantage. Course to build a production-ready app 👉 robertbrunhage.com/course
    00:00 Overview
    00:32 Folder by Type
    01:34 Folder by Layer
    02:15 Folder by Feature
    03:14 Dart Packages
    07:02 Announcement
    ····················································································
    ♥ Become a Patreon supporter: / robertbrunhage
    ♥ Subscribe: bit.ly/2SUyRhx
    ····················································································
    ● Website: robertbrunhage.com
    ● Twitter: / robertbrunhage
    ● Discord: / discord
    ● Instagram: / robertbrunhagedev
    ● Facebook: bit.ly/RobertDev

Комментарии • 88

  • @Lensbreak
    @Lensbreak 3 года назад +32

    Please make tutorial: folder by feature architect + riverpod hooks + flutter hooks + firebase

  • @davidowens9597
    @davidowens9597 3 года назад +10

    Folders under lib: models, views, controllers, and services. MVC+S design pattern. The views folder has a folder for each page/screen with the page widget and all widgets on the page in the same sub-folder. Widgets used by multiple pages are in the root of the views folder.

  • @SarveshBhatnagar1214
    @SarveshBhatnagar1214 3 года назад +4

    This was informative. Thank you for the video, not many people have talked about this stuff before.

  • @math045b3
    @math045b3 3 года назад +7

    I'm using by layer for my biggest project (also my first) and it's quite annoying, but changing it is also frustrating. For all other projects I use by features even for the small ones it makes so much more sense to me

  • @PadamShrestha
    @PadamShrestha 3 года назад +19

    Waiting for a full project tutorial based on folder by feature architect + riverpod + flutter hooks 🤪

    • @techzone2009
      @techzone2009 3 года назад

      I have built a project using riverpod and folder by feature ..chaiyo vaney dimla

    • @PadamShrestha
      @PadamShrestha 3 года назад

      @@techzone2009 sure.

    • @juniordev4190
      @juniordev4190 Год назад

      @@techzone2009 If you could write. Project nai chaiyena baru euta blog with examples vae ni hunxa.

  • @longtimedeveloper6498
    @longtimedeveloper6498 3 года назад +7

    Very nice work Robert, I've started using folder by feature. This really makes it easy to migrate to a package when needed. Best, Karl

  • @moazelsawaf2000
    @moazelsawaf2000 3 года назад +2

    Very very very great video ❤
    I was looking for a way to make my code reusable to use it in multiple projects and I've found it! ❤
    Thanks a lot, sir ❤

  • @albanr8028
    @albanr8028 3 года назад

    Exactement le tutoriel que je recherchais ! Merci !

  • @patricklearn6536
    @patricklearn6536 3 года назад +1

    Amazing video thank you!

  • @letsclode
    @letsclode 3 года назад +1

    Been waiting for this.

  • @user-gp1tr4kr4d
    @user-gp1tr4kr4d 3 года назад +1

    data -> models ,
    services -> local , http
    ui -> screens -> screen1, screen2
    widgets
    blocs -> bloc1, bloc2

  • @AkashdeepSingh-my9rr
    @AkashdeepSingh-my9rr 3 года назад +1

    This is really awesome. I'll follow up this structure . Thanks 😊

  • @nikhilkukreja8498
    @nikhilkukreja8498 3 года назад +3

    Thank you so much Robert. I generally used to make screens,models kind of structure. But folder by feature is really great approach i liked it. And i have already subscribed to your emails on your website. God bless you always :)

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      Glad I could be of help Nikhil!
      I appreciate all the support you give 🙏

  • @workflop4117
    @workflop4117 3 года назад

    Thank you so much amazing video 😍

  • @MrVipulLal
    @MrVipulLal Год назад

    Good one, sir! Thanks

  • @MdSiam-kw5ox
    @MdSiam-kw5ox 8 месяцев назад

    Thanks for this video man. 👍

  • @adambartosik357
    @adambartosik357 2 года назад

    thanks for this video! ;-) Good explanation of Packages / Modules

  • @gyakhoe
    @gyakhoe 3 года назад +3

    Mine is folder by feature but I make additional folder(as per folder by layer) inside each feature
    lib
    --feature1
    ----ui
    ----bloc
    ----data
    --feature2
    ---ui
    ---bloc
    ---data

  • @miroliebschner426
    @miroliebschner426 3 года назад +1

    Your videos are really the best out there. I haven't yet but I really consider donating via your Patreon which would be the first time I use Patreon ever.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      Thank you so much it really means a lot!
      I am just super happy the videos are helpful, that was the goal all along 😊

  • @replicasensei1204
    @replicasensei1204 3 года назад

    Intuitive....tnks

  • @arsarsars1able
    @arsarsars1able 3 года назад +3

    Good information, helpful for big projects.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +1

      Thanks!
      The more we know the more educated decisions we can make 😊

    • @arsarsars1able
      @arsarsars1able 3 года назад +1

      @@RobertBrunhage yeah ✌

  • @m.sulthanalihsan464
    @m.sulthanalihsan464 3 года назад

    thanks man, i like your video..

  • @i.k.shaikh3772
    @i.k.shaikh3772 3 года назад +1

    Very well done ✅

  • @mruduladdipalli5417
    @mruduladdipalli5417 3 года назад +1

    Awesome

  • @ianmcelvain9627
    @ianmcelvain9627 3 года назад +1

    The Stacked pattern from FilledStacks makes the most sense to me for production. This brings a lot of folders and .dart files into your structure but in my experience, most of the time it’s better to work in laid out, readable projects/code than it is to work with condensed code or folders in the effort to look clean and efficient.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +3

      Hmm I am not quite sure I follow, you can still follow @FilledStacks pattern but create everything in the same file if you want to (not recommended). The folder structure is not a rule and should (most of the time) change depending on how projects grow (in my experience).
      I have background in Angular and they have great documentation on how they do folder structure (LIFT) which I like a lot. In the end, this is to provide knowledge and not decide how you SHOULD do something 😊

    • @ianmcelvain9627
      @ianmcelvain9627 3 года назад +4

      @@RobertBrunhage I completely agree with this and I wasn’t trying to come off as one rule for all, that goes against programming and general engineering. This is just my preference, as you said in the video to drop them in the comments.
      I come from (day to day) C, C++ mainly for game engine programming so things like grabbing resources outside the folder dir of the script, I’m used to. General app development and web have always looked very messy to me, almost unstable in both conventions and methodology of making systems. The pro of that is that there is a lot to learn from the methods on the internet. One of the biggest practices is separating business logic from UI and that’s why when I refer to Stacked I also mean the minor folder structure convention that is with it because the interpretation of that methodology of separation makes sense to me.
      But preferences aside, your videos are extremely helpful and shine a light on production practices that are shadowed when first learning Flutter. E.g., creating an actual AppName.dart/class to be called into void main() instead of having main + MyApp class in one file lol so minor but helps start clean code.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +2

      @@ianmcelvain9627 Oh hope I didn't come off as rude, it was not my intention! Sorry if that was the case.
      Thanks for sharing your experience and I think many will benefit from it!
      Thanks for the support and super happy you liked the video :)

  • @priyanshparmar819
    @priyanshparmar819 3 года назад

    I wanted to integrate notification in my project. I am using folder by feature approach. Where should i add notification functionality, should i create new feature for managing notifications?

  • @rsajdok
    @rsajdok 3 года назад +4

    I have had a problem if should I use struct by layer or feature and how to separate a part of application for another one. Now, it seems clearly for me, thanks

  • @hawkybae
    @hawkybae 3 года назад +5

    Folder by feature works for me. Definitely going to look into creating packages for reusable functionality! Thanks.
    Also any hints on what the upcoming course maybe about? 😉

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      Super happy you liked it!
      Want to have project based courses so we will see 😊

  • @d34dsouI
    @d34dsouI 3 года назад +4

    Thank you Robert. Could you please make a video for explaining repository-services-stores-ui layered architecture especially suggested by mobx? Especially, I don't get what is repository and services layers and how to create and use them.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +2

      Will write it up, I want to cover more architecture approaches as well!

    • @geraldcampana9296
      @geraldcampana9296 3 года назад

      cant wait hehehe!

  • @user-nu2nj7mf2z
    @user-nu2nj7mf2z Год назад

    Hi RUclipsr! Thank you! I liked this video. I was struggling with adding dependency in Flutter project which dependencies were ignoring each other. The Package Structure Folder approach gives me an idea how to handle that issue. Nice job!

  • @fabsync
    @fabsync 3 года назад +1

    Robert.. thanks a lot for this video.. I think I would love to see the structure of a one of your big projects in a video.. There are many challenges also (I think) in terms of organizing big projects by features...specially when in a big project you may have 50-120 pages and each page may have 10 to 50 features..

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +1

      It depends on how small you think of features. I work at a very big company where folder by feature is implemented (or in android by module) which works great and that project is huge. I suggest giving it a try :)

    • @fabsync
      @fabsync 3 года назад +1

      Thanks Robert! Modules grasp better the concept for me than features :)

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      @@fabsync You can do pretty much the exact same thing with dart packages if you prefer that more!
      There are no hard rules here, just do what makes most sense!

  • @alihesari2703
    @alihesari2703 3 года назад +1

    great great great

  • @danielm3977
    @danielm3977 3 года назад +1

    Thank you Robert. Very informative video. Just a newbie question: In the Controller folder, What types of structure we put in. Tbh I googled it but not sure if I know exactly what "Controller " is. Best wishes.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +1

      These folders were just examples, if you are not using those in your projects you won't be using that folder!
      It was just for illustrational purposes

  • @RohanSingh-qg1jw
    @RohanSingh-qg1jw 3 года назад

    I'm pretty new to coding- what are controllers and repositories?

  • @madhusudhanr3527
    @madhusudhanr3527 3 года назад +2

    Thank you very much. I always have problem with the folder structure. BTW How do we create package like @personal/auth, @personal/database etc?

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      What do you mean with @personal/?
      You can define it however you want aslong as you reference the correct path and that it is a package :)

    • @madhusudhanr3527
      @madhusudhanr3527 3 года назад +1

      @@RobertBrunhage I meant like naming packages like npm private packages.

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      @@madhusudhanr3527 Have not tried that so if you do, let me know of the results!

    • @madhusudhanr3527
      @madhusudhanr3527 3 года назад +1

      @@RobertBrunhage Thanks for the reply and will surely let you know if it works. A suggestion for future video. "SSL pinning in flutter apps"

  • @OtarBediashvili
    @OtarBediashvili 3 года назад +1

    Great video and great explanation, thanks. pub get button seems useful. How can we get it?

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      Hmm I just always had it so thought everyone did haha

    • @mortenfriis
      @mortenfriis 3 года назад +1

      It should be available to you when you're in the pubspec.yaml file.

    • @OtarBediashvili
      @OtarBediashvili 3 года назад +1

      Yeah, that's correct

  • @tasehagi
    @tasehagi 3 года назад +2

    Hi. Thanks for the video. I have one question: how does modifying a local dart package work? Do I see the changes immediately? Do I need to run 'pub get' again?
    Also I see your website is a ReactJS app 😂

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +1

      You will see the changes immediately!
      Yes, sadly Flutter Web doesn't have the things I want right now (especially as I am moving to Next.js soon) :(

    • @dhanniekristanto
      @dhanniekristanto 3 года назад

      @@RobertBrunhage actually I'm planning to try flutter web for personal site.
      There's also something I want but still couldn't do it in flutter.
      Webview(type: script, link: gist link).
      anyone know a package with that kind of feature?
      by the way, great video, learn something new. Thanks Robert

  • @RobinJesba
    @RobinJesba 3 года назад +1

    What Theme do you use for VS code?

  • @fethi2436
    @fethi2436 3 года назад

    What is the theme you are having on vs code, folder icons look nice

    • @lambda-dev
      @lambda-dev Год назад

      I think it is material icon theme, looks great :)

  • @SamSam-rg4lk
    @SamSam-rg4lk 2 года назад

    In Folder by Feature structure, what's the difference between a repository and a service?

    • @lambda-dev
      @lambda-dev Год назад

      I use repository for infrastructure, so storing data or calling apis. Services should contain and transform business logic independent of the view. Hope this helps :)

  • @YazeedAlKhalaf
    @YazeedAlKhalaf 3 года назад +1

    I made a vs code extension for making my folder structure, tell me what you think?
    GitHub: github.com/YazeedAlKhalaf/Stacked
    VS Code extension link: marketplace.visualstudio.com/items?itemName=YazeedAlKhalaf.stacked

  • @rebarius
    @rebarius 3 года назад +1

    🍪🍪🍪 All my cookies for you 🍪 never thought of structure by feature 🍪

    • @RobertBrunhage
      @RobertBrunhage  3 года назад

      It's super easy to work it, and I like it a lot :)

  • @budisetiawan2499
    @budisetiawan2499 3 года назад

    well the packages structure is the default structure in android studio so i would suggest anroid studio, IMPO

  • @void4904
    @void4904 3 года назад +2

    I would be really happy with English subtitles 🤣

  • @hosannaamane6031
    @hosannaamane6031 3 года назад +1

    Awesome \(uu)/

  • @nagcvlogs
    @nagcvlogs 3 года назад +1

    How can i give 1Million likes to this video......

    • @RobertBrunhage
      @RobertBrunhage  3 года назад +1

      If you click a lot of times and really fast maybe we can get 1 like on it!!!!

  • @sergiorodrigoroyo5079
    @sergiorodrigoroyo5079 9 месяцев назад

    I can't believe some people still structure folders by layer. It must need some real inclination towards BDSM.

  • @munawir7013
    @munawir7013 3 года назад

    sub english please

  • @ThEGeEeK
    @ThEGeEeK 2 года назад

    Please make tutorial: folder by feature architect + riverpod hooks + flutter hooks + firebase