Top 5 Flutter Tips for Big Projects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
when you create a new project it usually starts off really small but as time moves on it starts growing tremendously fast and there are some things we can do to make that journey smoother when applying these different tips the long term complexity of our project will be improved a lot now the sole biggest thing for any kind of sized project is that you should keep refactoring to heart but right now i won't talk about refactoring but instead these five tips that you can apply right now in your project make sure to like and subscribe and find the full write up on robotpronog.com and starting off with the first tip which is linting let's say you want to prioritize using const as much as possible but you usually forget when to use it well there's a lint rule for that and a lot more in this example we'll just use the lint package from flutter and art but there are a ton of different ones so pick the one you like the most navigate to your project and start navigating to the pubspec yaml file add a package of your liking and run packages get now one thing we have to do more to make it work is that we have to create a new file in the root of the application and it's going to be called analysis options and in here we will just include our package and right off the bat moving off to the main.charge file we can already see that we have some warnings and in this package we prefer cons constructors so we'll just add at and we can see that the warning goes away now if there are rules that you don't want or want to change some kind of rules you can always add that in the analysis options file by overriding the specific rules now this example just comes from the package documentation but we'll remove that as we don't really want to do any overrides on this one for now and that's all for linting now the next tip is regarding packages with packages it makes it easier to separate code and make it more reusable this approach is pretty much the same as when you get a package from pub.dev the only difference is that you personally have it in your own project or you have it on your own github repo and this is quite simple to implement go to the root of your application and create a folder called packages let's say we want to be able to have all of our authentication logic in this package in the end this will hold all the logic for things like signing in signing up resetting password and so on we only need to create one file which is the pubspec yaml file now to make this simple i just copied everything from the main project's pubspec yaml and paste it in here i went ahead and removed all of the comments and we can start by changing the name description and so on now let's go ahead and just remove all the spacing and just for an example we'll keep the flutter dependency because maybe we want to have some kind of ui elements in this package by used saving and running packages.get we can see that we have a bunch of new generated files and these files together make up what we call a package in this authentication package we can create a new folder and just call it lib and here we can create all of the files that we want to use let's say we want to create a new file and call it authentication in this case we will just create a empty class which is called authentication but in here you could have all of the logic that you wanted to have for the authentication to work let's close everything and move to the pubspec yaml of the entire project now we can start importing the package so pretty much the same thing we did with the lint package we defined that we want to use the authentication package which is the name of authentication and now as this doesn't come from pub.dev we need to specify the path and as the package is in our project packages folder we will use to specify that specific path so now if we run packages.get again and move over to our main.dart file in our project now we can import it like any other package and of course we can follow the code so let's try and control click on authentication and we should see that we get into the file in the package and now you could even upload that package to github and use it in other projects now for this next tip which is cicd and i already have a full video of this utilizing github actions where you can get all of this completely for free but to utilize cicd fully we have to do something called testing and this is the notion of making sure that the code you write for your project actually does what you intended it to do now i have a full video regarding testing for complete beginners so make sure to check that out now the last tip is regarding filming because the last thing you actually want is having random colors scattered for your application and you finally realize that you want to implement dark mode and you have to go through your entire application to find all of the colors and replace them though what we could have done instead is just simply going up to the top of the application at the material app where we have the film we start using our colors in the film as well as the dark film so for example you could have a file with all of your colors already defined in this case i'm just going to use the material colors used to showcase this for example in the light mode you want to have a primary color of blue and for card colors you want it to be red now if we use the films everywhere the card colors would already be set thanks to the film now let's say we want to change up the card color for both the light film and the dark film so for the dark film we can select copy with and set the card color to a new color we're going to set this as the same as before but we're going to add another shade to this red color for the light mode we will do the same and instead have a lighter shade of red and now thanks to the film all of the colors that we have not overridden for the cards will use these new colors make sure to check out these videos coming up on the screen right now have a great day
Info
Channel: Robert Brunhage
Views: 31,634
Rating: 4.9575472 out of 5
Keywords: Flutter, Flutter Tips, Flutter large projects, Flutter production, flutter testing, flutter ci/cd, flutter ci cd, flutter theming, flutter scale project, flutter packages, flutter custom package, flutter github actions, flutter architecture, flutter UI, flutter design, flutter tutorial, flutter for beginners, Robert Brunhage, App Development, Android Development, Crossplatform development, flutter 2.0, flutter 2.2, flutter recap, flutter news
Id: QETClbz1sz8
Channel Id: undefined
Length: 5min 54sec (354 seconds)
Published: Sat Jun 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.