Tips for production app with Flutter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to channel codex I'm your host afzil and in this video we're gonna talk about the seven things which you should be careful when you're creating production ready application [Music] we all have gone through the learning phase of flutter at one point of time right and we discovered all the features by creating the demo projects watching all the tutorials like you're watching right now but as soon as you step to production ready application and you start creating for production you should be careful about these point which we are going to discuss in today's video now the first point which I want to highlight is having a helper for your dependencies and obviously you are not going to create helper for every single dependency but there are certain dependencies which you know that it exists for a certain feature like accessing a battery level or invoking some of the hardware features of the device let's take an example of vibrate plugin so what generally we do we just import this feature inside our view or controller directly now think about that you have this feature in seven different pages and for some reason you have to update the package or you have to change the package then you will be revamping all the seven pages or everywhere where you have used this package So to avoid this situation you should create a helper class which is responsible to perform all the operations you need from that package so say for example I will have one method for vibrate and one method for haptic feedback now from every single place you will be just calling these two methods and anytime if you want to change the package or if you want to upgrade it or you know just replace the package you just have to change in one single file and all the other things will remain unimpacted and that's how you create a maintainable project now moving to the second point and be mindful of your dependencies now what I mean with that a lot of time it happens that in hurry you pick a package to just get your work done without looking at how often it is updated and what are the pop points it has and looking at all the best practices uh what a package should follow anything which is updated before six months you should avoid such package make sure it has an unsafety feature and make sure the pop points are at least 90 or above and if you're already following these practices kudos to you let's move to the third Point minimize your widget tree again the point is same when you are into hurry you just keep wrapping your widget with a container with the padding and lot of other widgets which are not really necessary to achieve the same look and feel don't do that mistake your widget tree should be as minimal as possible so if something can be done with the container don't add a padding if some something can be done with the scroll view alone right scroll view itself has a padding so you don't need to add another widget because it will create a render object it will create a Elementary so those all thing you don't want to jump into that and add extra overhead for your application performance so avoid having extra widget try to create your UI with as less widget as possible now the tip number four is more related to your coding organization what happens when we are developing a demo application we end up writing you know all the padding values and all the sizes directly inside a view because we are into exploration of the feature and we don't want to change these values later on it's just one time project but in production application you're going to use the same values again and again in different pages so it's a good idea to put them in a constant file you can create a constant for size for colors images strings and whatever you like just make sure that it is relevant to the file and you can use these values anywhere inside your project and trust me it will save a lot of time for you and your UI will be consistent with these values now tip number five is related to productivity tip or you can also say as UI tip in a bigger projects we generally have the same component used at different places say for example the button you have the button on a login on a sign up and everywhere else you have the same look and feel of the button so instead of writing material button on every single page with providing all the shape and all the look and feel you can create a custom widget and give just unnecessary data to populate what your template looks like for example you can create a custom button and provide this with a property title Now from anywhere inside your application you just have to call Custom button and just give one line that this should be the title it will take care of the radius it will take care of the Shadow or whatever look and feel of your application let me tell you that I have a dedicated video on creating a custom widget and how to pass all the parameters how to have events how to pass uh you know information back from those widget to your page with functions void callback and everything you need to know about creating a full-fledged custom widget for your application you will find that video in the description section below and also I have pinned that as a first comment now before we move to the next topic let me tell a moment and thank all the channel members who have recently joined Channel codex thank you so much for that I really appreciate and also I request you guys to become a member at The Geek Squad or Pro Squad you can click on the join button and you will see all the feature details over there and before it gets too late let's get back to the video now Point number six that you should follow for your production application is instead of creating a method for your widget you should use stateless widget now there are so many debates that writing a stateless widget is more performant than having a function but in my opinion you should stick with a stateless widget because it is recommended by flutter that's the first point and the second one you got the context with your stateless widget whereas in the function you are not going to get the context uh you know unless and until you pass it which is going to be your parent widgets uh context not that widget context so you should stick with stateless widget instead of going with a method now the seventh and final tip you should always listen to the linter so your linter is going to guide you to become a better developer it will tell you what is recommended by the community it will tell you what dot recommends so just listen to it keep checking the values in the bottom left corner how many linter issues you have and try to address them as soon as possible so that it doesn't get piled up all the unnecessary Imports all the lower uppercase variable declaration so you just keep on improving those areas that that will make you a better developer I really hope that these seven points will help you to create a better application and also at the same time it will make you a better developer in terms of following the best practices taking care of your dependencies using constant files minimizing the widget tree and all those things so it's just you know a sum up of the best practices for production ready application thank you so much for watching I will see you guys in the next one
Info
Channel: CodeX
Views: 9,970
Rating: undefined out of 5
Keywords: flutter, tutorial, how to, android, ios, ui, production, tips for flutter
Id: 6B9iURpGObg
Channel Id: undefined
Length: 7min 34sec (454 seconds)
Published: Sat Dec 31 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.