Best Flutter Widgets EVER!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is the top 70 flutter widget let's start right now the material Banner widget and this is what we will be able to create you have a little pop-up from the top that you can demise at any time to create this we'll start with the center widget an elevated button with the text open the on press function will have the scaffold messenger that of contexts.show material Banner inside we use the material Banner widget you can create a padding the content will be just the text subscribe so you can see it's disinformation the leading will be a Nikon notification the elevation will be 5 the background color white 12 and the actions will have a text button with the unpressed function that will trigger the scaffold messenger that of context that hide the current material Banner the child will be the Miss and just like this you have created a material Banner with your flutter app the preferred size widget this can be used to create your own app bar widget so the first thing you need is to create the preparate size widget inside the app bar of the scaffold the argument prepared size will be a size from height and we will use 80. the child will be a container with the height 120. the decoration will be a box decoration because we want to have a gradient we will use the linear gradient Widget the colors of the gradient will be color red and orange next we need to create a child which will use the safe area the child will be a center and the child of the center will be a list tile widget we have the title flutter map and the trailing icon search and just like this you have created your own app bar Widget the bottom sheet in a center widget we will create an elevated button this one will have a text model bottom sheet and when we press on it this will trigger the show model bottom sheet you will need the context inside and a builder the Builder will have also the context and this will return a size 8 Box by example but it can be any widget we will set the height at 400 inside we will have a center widget with a child elevated button this one will have the text close and when we press on it this will trigger the navigator.pop context in other words this one will be used to close the bottom sheet and when you press on the model bottom sheet you will see that the sheet is coming from the bottom inside your app and you can also close it and the animation is all done for you the long press draggable widget this one can be used to select an item and move the location of the item so let me show you how it works first we create a variable offset which will be the location of the image when we start then inside the center widget we use a layout Builder this one have the context and the constraints we will need this to know where is the location of the widget inside we will use a stack widget which will have children the first one is the positioned so we will position the widget from the left with the off set dot x-axis we will do the same thing with the top with the offset dot d y inside we have the child which will be the long press draggable the first argument will be the feedback it will be an image network but with a color or range and a blend mode color burn the feedback is the image we can see on the screen when we drag the widget after this you have the child widget which will be also an image but this one is the original image the argument on drag end will have the details and inside you will set State and create an adjustment of the image location after you will set your offset variable using the adjustment we just created and just like this you have created a long press draggable widget which can be used to move anything inside your app the interactive viewer widget you can use this to zoom inside your application you can see this is a widget inside a scaffold which I can zoom and the zoom and this is because of the interactive viewer let me show you how to create this first we will start with the scaffold Widget the background color will be orange accent the body will be the interactive viewer inside we will set the boundary margin to Edge and sets dot all double infinity the child will be another scaffold with a NAB bar and now you can see that I can move the scaffold pretty much everywhere and I can also zoom and the zoom everywhere inside this scaffold but keep in mind that you can use this for any widget the reorderable list view on the screen we have a list but we can reorder every item inside this one first we will need to create a list of items this one will be a list that generate of 30 items next we use the reorderable list view widget inside we have the children which will be a list that generate also the items that length will be the number of item inside the list and then each item will be a list style make sure that you put the key which will be in this example a key with the index inside the tile color will depend if the item is odd or not the title will be the item and the index of the item the trailing will be the drag endl sharp icon and after you need to create the on reorder this one will give you the old index and the new index with this you can create a logic you can say set state if the old index is smaller than the new index then you will say that the new index is -1 you can then create a final item is equal to item that remove at Old index and then insert the item at the new index location this is just all the logic to make sure that when you move an item it go to another place and this was how to use the reorderable list view with flutter the checkbox list style first thing we need is a Boolean is checked set as false in the center widget we will have the checkbox list style you will need to have a title this one will be a text checkbox list style the value will be the is check head from the Boolean that we have created earlier you will need the unchanged argument and this will give you the new value of the checkbox inside you will say set State and the is checkhead will now be equal to the new value you can change the active color I will put a range accent the check color will be white and if you press on the button you will see it's white and with the orange accent background you have also the argument tile color which will be black 12 12 a subtitle text this is a subtitle and if you want you can switch the location of the check box by using the control Affinity list style control Affinity dot leading the argument Twisted through will allow you to have the check head null or uncheck it this was the checkbox list style the circle Avatar widget in a center we will create the circle Avatar inside we will have the background color which we will say orange accent you can have the radius 55 if you want to change the size and I will add a background image which is an asset image from my assets and this will create a circle around your image if you need you can also have a child inside the circle Avatar this will be a text saying hi and this is how to use the circle Avatar with flutter the Cupertino context menu and this is what we will create a button that will trigger two different action inside the center widget we will create a size 8 box first with the width and the height 100 inside we have the child Cupertino context menu this one will take a child in this case it will be the image Network and it's the YouTube image the actions will be a list of Cupertino context menu action the child will be a text action one and the unpressed will have the navigator.pop context we will do the same thing with another Cupertino context menu action the child will be a text action too and the on press will be a navigator.pop and with this you have created an image button that when you press on it you have two different options the action 1 or the action 2. and this was the Cupertino context menu the table widget this is what it looked like and I will show you how to create this right now first we use a center and a padding widget inside we use the table Widget the Border will be table bordered at all with the color white 30. the default vertical alignment will be in the middle the children will start with the table Row the decoration will be a box decoration with the color red accent this will be the color of the first table row inside this one we have multiple children we will use the table cell in the child we use a padding widget with the child text Title One this is the first cell you can see on the screen we will also add two other table cell and I will save the application now what I will do is after the table row I will create a list of multiple table row by doing list.generate with 20 items each of them will be a table Row the children will be three table cells with the text cell 1 2 and 3. and now you have access to a table in your app if you want to make sure that this list is scrollable you can wrap everything with the single child scroll View and now you will have a scrollable table inside your app the alert dialog widget inside the center of our application we will have an elevated button this one will have a text show alert dialog and when we press on it we will show a dialog this will take the context and a builder the Builder will return the widget alert dialog inside you can have the actions which in this example we will use a text button with the unpress navigator.ofcontext.pop and a child saying close you can also have a title inside the alert dialog we will say flutter map the content padding will be a edge and sets that all 20. and the content will be a text this is the alert dialog with all this you have generate this button and you have this pop-up when you click on it this is the title this is the content and this is the actions the animated container let's start this one by adding a Boolean selected set as false the gesture detector will have the on top and the child Center the on top will set State and reverse the value of the selected again the selected is the Boolean that we have set at the beginning in the center we will have a child animated container for the width if the selected is true it will be 200 otherwise it will be 100. the height will have the same logic if it's selected then it will be 100 otherwise it will be 200. the color of the animated container will be blue gray if the selected is true otherwise the color will be white now for the alignment we will see if the selected is true then the alignment will be Center otherwise the Allen man will be top Center the duration of this animated container will be 2 second we can also have a curve which will be fast out slow in the child of the animated container will be a flutter logo with the size 75 and you can see that when I press on the gesture detector all the characteristics of the animated container will be animated the width the height the color and the alignment of the child this widget is very simple to implement the card widget inside the center of the app the child will be the card widget you can change the elevation of the card and the color if you need the child will be a padding the padding will be all in set 15 and the child will be a column with the main axis size minimum the list of children will be the size at box height 8 attacks this is a flutter card and a simple text button with the text pressed and the orange thing is what we call the card it's like the container widget but you have an elevation and rounded Corners the date picker with flutter and you will see that when you click on this button you have access to a calendar and you can select any date to have it on the screen right after and I will show you how to create this right now the first thing you will need is the date time selected date this one is a date time dot now and inside the center widget in a column we will have the list of Widget the first one will be a text widget inside we will have the selected date.year dot month n dot day right under we will create an elevated button the child will be a text choose date and the on press function will be async inside we have the final date time nullable call it daytime this one will await the show date picker inside this one we need the context the initial date which is the selected date we created the first date I would say date time.2000 the last date I would say date time that 3000 and right after you will say if the date time is not null then we will set State and say that the selected date is equal to the new date time and just like this you have created a calendar with your flutter app and you can select any date the time picker with flutter and I will show you how to create something like this you will be able to select any current time and this will be display on the screen to create something like this you will need to start with a time of day which we will call selected time this one will be a time of day dot now and inside the code we will have a center a column and inside the children of the column we will start with a text widget this one will display the selected time that hours and the selected time that minutes and this is what you see on the screen right now under this one we will have the elevated button the child will be a text choose time and when we press on it this will be an async function we will have the final time of day which is nullable is equal to a weight show time picker inside this one you will need the context the initial time which is the selected time we have created you can also create the initial entry mode for this example I will use time picker entry mode dial and after this you will see if the time of the day is not null then we will set State and say that the selected time is equal to the time of the day that we have received from the showtime picker and just like this you have created a Time picker with your flutter app the date range picker with flutter this will allow you to select a range of date in your flutter app I will save and you will see that by example we have 17 days between those two dates so let's call this right now first thing we need to create a date time range and this one will need to have the start which will be date time dot now and the end date time that's now also with this one we can go inside the center and the column widget and create a text widget that use the text selected date.duration dot in days this will allow us to know how many days there is between those two dates and if I restart the application you can set we have zero days because the end and the start is the same time under the text widget we will create an elevated button this one will have the child text choose dates the unpressed function will be async and inside we have the date time range is equal to a weight show date range picker inside we have the context the first date which will be 2000 the last date which is 3 000 and after we need to say if the date time range is not null then we set State and the selected date is equal to the new date time range with this you have a way to select a range of date inside your flutter app the dismissable widget let's say you have a list of item and you want to remove items inside the list this is the dismissable widget and I will show you how to use it right now first thing first we will need to create a list of int which we call items to generate this one we would say list the generate 100 items and each item will give us an index that we will store inside the list in other words this is a list of 100 numbers in the return we would say listview.builder because we want to create this list then you will need to say item counts items.length the padding will be vertical 16 and the item Builder will return the dismissable widget you can design the background of the dismissable widget in this example I will just use a red container inside we have the icon delete and you can see that when I scroll I have the icon delete with the red color behind this is the background next we need to have the key and for this one I will use the value key int and inside I will put the index of the item so the key will be one two three four five and so on this will be important because we want to keep track of items that we delete after we have the undemist widget this will give you a diminished Direction so you can decide which action will be triggered if the user go from the left or from the right but for this example I will just set State and remove the item from the current index the child of the dismissable will be a list style the title will be a text with the current item and with this code you have created a list of dismissable items the Dragon Ball scrollable widget as the name said you will have a draggable list of scrollable items for this one you will need a Dragon Ball scrollable sheet inside you will have the Builder which have the build context and the scroll controller the return will be a container with the color orange the child will be a simple listview.builder inside we will put the scroll controller that we receive from the draggables scrollable sheet the item count will be 25 the item Builder will have the context and the index which will return a list style of each items and just like this you have created a draggable and scrollable sheet the drag Target widget and this is how it will look you will be able to take a draggable widget and put it inside the drag Target widget to create something like this we need to start with a variable cuff color which will be red in a size that box with double infinity we will have a column and in the column we will have a draggable widget this one will have the data color or range accent and the child will be a container with 100 100 with the color orange we need also to create a undragable canceled and also a feedback this one will be also a container with the color orange accent with opacity 0.5 and this one is the widget when we drag over the screen now that we have a draggable widget we can create the drag Target inside you will need to have the unaccept argument this will be the data that you receive from the draggable widget and inside this function we will call the cut color is now equal to the color we need also to create a builder for this one we will have the build context the list accepted and the list reject we will return a container this one will have a width 200 by the height 200. the color will be if the accepted list is empty then it will be the cut color otherwise it will be the color gray shade 200. the child will be a center widget with the text drag here and you can see that the drag Target is currently the cuff color and as soon as we take the draggable widget and put it over the drag Target it is the gray color shade 200 and as soon as we release the widget the color is now cut colors this was the drag Target widget draggable widget it's a widget that you can take and drag anywhere on the screen for this example we will create a cut color red and inside the sized box we'll create a column with multiple widgets we will use a drag Target widget so we will be able to take the drag ball and put it inside this one have the argument unaccepted have a builder and return a container 200 by 200 with the text drag here inside for the draggable widget we will put it over the drag Target and you will have the data argument this one can be any object but for this example we will use the color or range accent this is the information that will be used later in the drag Target widget we need also to create a child this will be a container 100 by 100 color or range accent and the text box you can see it's this widget you can add also a undragable canceled this will be triggered when you take the widget and don't complete the action the feedback would be a container with the width and height of 150 the color will be orange accent that width opacity 0.5 the child is a center widget with the text box and three dots this is the widget that you are currently dragging you will also need to create a style for the text I will use a color white and the font size 18 and just like this you have created a draggable widget that you can put inside the drag Target Widget the animated Crossfade widget we start by creating a Boolean set as true inside the column we will have multiple children the first one would be a size 8 box with a height of 100 on there we will have a text button this one will have the unpressed that set State the Boolean to the invert of the Boolean and the child of the text button will be a text saying switch this will be used to trigger the animated Crossfade Widget the third widget in inside the column will be the animated Crossfade the first thing we need to add is the first child which will be an image the second child will be another different image and then you can use the Crossfade state if the Boolean is true then we will say Crossfade state DOT show first this will show the first child otherwise Crossfade state that shows second this one will show the second child the duration of this animation will be once again with all this when you press on the switch button this will animate a fade transition between the two widget or two widget is only two image but you can do this with any widget the drawer widget you can click on this button and this will open what we call a dryer which you have two elements inside to create something like this with flutter you will need inside your scaffold to use the argument dryer inside the widget you will have a child we will use a list View and will have two list style inside just like this you will have a button to open a dryer but how can you create a button in the middle of the screen to open this dryer for this we will create in the Buddy a center widget with the elevated button then we will wrap the elevated button with the builder widget and inside the unpress we will have the scaffold that of contacts that open drawer and just like this you can open the dryer from a button if you want you can change the location of the drawer by using instead the end dryer and now you will see it will open on the right side and if you want the button to work you will need to use the open end dryer just like this you have created a drawer within your flutter application the drawer header widget first we will need to create inside this scaffold Edge wire this one will have a list View and the children will be too listile you can see that this will create a drawer on the screen but you can add the dryer header inside this one you can add a decorate operation I will use the color blue and then a child that takes his drawer header and you can see that now we have a drawer header the pop-up menu button on the screen we have a list style and when we press on the icon we have a pop-up menu and you can select the second item to change the list style to create something like this we will start with three variable the title the item one and the item two the title is what you can see on the list style next inside the list down we will create the title which will use the text title the trailing will be the pop-up menu button inside you will use the item Builder with the context and this will return you a list the first one will be a pop-up menu item the child will be the text item one which is first item and the value will be also item one you will create another pop-up menu item the child will be a text item 2 and the value also the argument on select will return you the new value select and you will be able to set State the application and set the title to the new value and with this you have created a pop-up menu button inside your flutter app the animated default textile widget we start by creating a Boolean call it first this one will be set as true we have also a double font size which will be 60 and a color that will be blue inside a column we will have multiple children the first one will be a size 8 box with the height 120 the child will be an animated default textile this one will take a duration which will be 300 millisecond the style will be a textile the font size will be the font size variable the color will be the color variable and the font weight will be bold this animated default textile will have a child which will be a text saying flutter to trigger the animation we will create the text button widget in the column the unpress will be used to set State inside we have the font size if the variable Boolean first is true it will be 90 otherwise it will be 60. the color will be the same logic if first is true then the color will be blue otherwise red and then we will reverse the value of the first Boolean the child of the text button will be a Simple Text switch and now every time that you press on the switch this will trigger the animated default textile and you can see that the size of the text is animated the color also the aspect ratio widget first we will start with a container with the color or range accent the alignment will be Center the width will be infinite and the height will be 150 this is what we have inside the child of the container we will have our aspect ratio the aspect ratio argument will be 16 by 9. this is the same as television and computer ratio inside we will have the child container the color will be blue gray and this is what we have you can see that this is the size of a computer now let's change the height for 300 and you can see that you still have the aspect ratio 16x9 and this is only possible by using the aspect ratio Widget the autocomplete first we create a list of string which we call the list items this will just be a list of multiple fruits apple banana melon inside the build we will return the autocomplete and inside we can say that this will be strings the option Builder will have inside the text editing value this is what we enter inside the text this is the input of the user if the text editing value the text is equal to nothing then we will return an empty list of iterable string otherwise we will return the list of item under certain condition for each item this is what we will do we will return the item if it contains the text editing value the text which is the input of the user dot to lowercase in other words if the user have written a this will return the apple and the banana you can also have a unselected this mean when the user click on a certain item for now we will just print the item was selected and you can see that when I go inside the app and I write a I will have the suggestion for Apple because we have the A and banana because we have a a if I write P this will only suggest me apple and this was how to use the autocomplete the error widget when I click on this button this will troll the red screen error but what you can do is use instead the error widget dot Builder just after the main this will give you the flutter error details and inside I will return a simple container the alignment will be centered the child will be a text widget with the error message I will also create a custom Style with the color orange and the text align that's centered now when I click on throw the error this is what I will see on the screen but if you want to see the red screen only when you use the debug mode then you can create a Boolean in debug is equal to false you can use the assert function which will be triggered only when you are in debug mode and then you set the Indie bug to through after you create the if condition if it's in debug then return the error widget detail exception in this way because I run the application in debug mode right now if I click on throw error this will still put the red screen but in production you will have the custom message error the expanded widget and this is how it will look if you have re-widget like this with different Flex value for this one inside the column widget we will create the expanded Widget the flex will be 2 and the child will be a container blue under we create another expanded with the flex 1 and the color orange the last one will have a flex three and a half the color red and you can see that even if the container have a certain height value the expanded widget will take all the remaining place and you can use the flex value to know which expanded will take more place than the others in this case this expanded widget will take three times the space of this expanded widget flexible widget in this example we will create three flexible widget inside a column and you can see that the flexible widget is doing absolutely nothing if the inner widget have a certain height but now if we remove every height of each container you will see that the flexible will be used and we Define how many space each flexible take by using the flex argument 5 is bigger than 3 so the flexible 5 will be bigger than this one and if you want you can convert a flexible widget into a expanded widget first let's re-add every height of each of them next I will add the argument fit Flex fit for each flexible widget and now you will see this is acting as a expanded Widget the expanded widget will always take as much place as possible even if the inner widget have a certain height and now I will show you visually what is the difference between the expanded and the flexible I've just replaced everything with three different Row the first one I have an expanded and a flexible and you can see how the application is displaying both of them if you have too expanded this is how it will look and if you have too flexible this is how it will look I hope this example help you to understand what is the difference between the expanded and the flexible widget loading action button widget in this one I will show you how to create a button like this but did you know that this button can be anywhere inside your application and to build something like this you will need to go inside your scaffold widget and create a floating action button inside the floating action button argument you have the on press function for this example we will have an empty function the background color is the color of the button we will use the orange accent the child is the icon that add and just like this you have created a floating action button but if you want you can change the floating action button location by using the floating action button location.centereduct now it will be in the center but you can use many other location like the center Float Center top or end docket at this point all depend of your preferences this was how to create a floating action button with flutter the form widget this widget will allow you to create a form within your flutter app and validate everything with only one button and to create something like this we will need to start by creating a global key which we will call the form key then inside a padding widget we will create a form the key will be the form key we just created and inside the child we will create a column widget this one will have children and the first one will be a text form field widget inside you can use the validator argument it will return you the value which is all the information entered inside the text field and then you can create conditions by example if the value is null and empty then we will return enter something other otherwise we will return null we will create another text form field just like this one and right under we will create the elevated button when we press on it if the formkey that current state DOT validate is true then we will trigger this careful messenger show snack bar in other words this will trigger the validator of every text form field inside the form and if the conditions are true then it will trigger the snack bar the child of the elevated button is a text validate and now you can see that if we have text inside both text field and we click the validate button we will see the snack bar and otherwise it will show us the error message and this is how to use the form widget with flutter the text form field widget this is the application you will have at the end we will start by creating a variable titles which is a list of string then inside a single child School view we will create the form widget we will make sure that the autovalidate mode is always and and then every time we change something inside the form this will set State and Trigger the form dot of primary focus.contacts dot save you will see later why we use this next inside the child of the farm we will create a column Widget the children will be a list dot generate we will create three items and each of them will have a padding and a child column inside this one we will create text form field widget which inside will use the unsaved this is a function that will be triggered every time we save the form and inside we will receive the value and say if the value is not null then the title of the current index will be equal to this value this is why we can see the text right under at the same time as the user is writing information after we'll create a size set box and secondly we will create a card widget this one will have a padding and the child will be a text title of the current index and so now every time you start write something this will trigger the unchanged function of the form widget which will set State and Trigger the save once the save is triggered this will trigger the unsaved from the text form field which at the same time will change the value right in inside the card widget and this was the text form field Widget the animated icon the first thing we will do is add the with thicker provider State mix in right after the extend State I will tell you why we need this later next we need to create a Boolean is play that we will set as false when we start in a late animation controller which we call controller with this we can create the init State and inside we will say that the controller is equal to an animation controller the duration will be one second and then we use the vsync this and we need the width ticker provider because otherwise the vsync this will not work I will put back the width ticker provider and then we will work on the dispose method inside this one we will just need to dispose the controller when we don't use it anymore now it's time to work on the UI in the center widget we will use a gesture detector the argument on tap will trigger a if else condition if the is play is equal to false then we will say that the controller dot forward and we will set the is play as true otherwise we will see the controller.reverse and the is play will be equal to false forward mean that we will have the next icon and reverse mean that we will have the previous icon the child of the gesture detector will be the animated icon inside we have the icon animated icon dot play pause this is the first icon and this is the second one the progress will be a controller this is an animated controller and we will say set the size at 100 if you restart the application you will have a play pause button that is animated this is called the animated icon the choice chip Widget the first thing we need is to create a Boolean is selected set as false in the center widget we will have a choice chip widget this one will have a label text Choice chip the selected will be the is selected Boolean we have created the selected color will be a color orange accent the unselected will give us a new state which is a new Boolean and say that is selected is now equal to the new Boolean like this you have created a choice chip that can change color when you click on it the fade in image widget when your image will load inside your flutter app this will display a placeholder before your image is loaded from the internet you can see that we have a placeholder until the image is loaded and to create something like this it's pretty simple with flutter we will start with the center widget we will create a child fade in image this one will be dot asset and network because the placeholder image is from the asset library and the final image is coming from a network the argument placeholder is from the asset library.icon.ocean gpg this is inside the asset of my flutter project now for the final image this is coming from the internet and it's the image that you can see on the screen so now when we restart the application you will see that the placeholder image will be display before the network image is actually load and this was the fade in image Widget the fractionally sized box widget this widget is exactly the half of the height of the screen and the half of the width of the screen and this is because we use the fractionally sized box let me show you how it works first inside the center widget you will use the fractionally sized box the width Factor will be 0.5 and the height Factor will be 0.5 inside you can put a child container with the color amber accent and now you have this container but if you change the height factor to 1 you will see this will take the entire height of the screen and this was how to use the fractionally sized box with flutter the future Builder widget when I press on this button this will wait until we have the data and then it will display everything on the screen so how do we use the future Builder the first thing we'll create is a future get data this will be an async function inside you will await a future delay for once again this just means we will wait for once again then we will return the data super we will use this true error later now inside the center widget we'll create the future Builder inside we will have the future which is the get data the Builder will have the context and the Snapchat inside you can say if the snapshot that connection state is equal to connection state that waiting so if we are waiting for the data then it will return the circular progress indicator and then we create another if else condition if the Snapchat has an error then we will return something and otherwise we will return something else so if we have an error we will display a text widget with the Snapchat dot error.to string and otherwise we'll return a column widget with a text that have the snapshot the data the tostring we will also use an elevated button and this one will have a set State inside the unpress function the child will be a text refresh okay so with all this when we press the refresh button this will trigger the function get data will wait for once again and then we'll return the data super but what will happen if we throw an error in this case it will return the error widget and this was how to use the future Builder with your flutter app the gesture detector widget in this example we have a simple container that we have wrap with a gesture detector so every time we click on the container this will trigger a function but you can wrap anything with the gesture detector in order to create a button to make something like this you will first create a int counter which will be zero inside the center widget will use a gesture detector the untapped function will trigger a set State and will add one to the counter the child will be a container with the height and width 200 and the color or range accent the child will be a center with the text counter.to string and we will add a style of font size 50. and this was how to use the gesture detector with flutter the grid view widget at the end of this video you will be able to create a list just like this one so first we'll use the grid view dot Builder inside we have the grid Delegate for this one we use the sliver grid delegate with fixed cross access count the the cross access count will be 2 because we want to have two columns the item Builder will be a grid tile widget and this one is the picture with the header and the footer the next thing you need is the item count we will create 10 item inside this list and with all of this you have created a grid view widget but keep in mind that you can also just use the grid view like this you don't need to have the dot Builder and this was how to use the grid view widget inside your flutter app the grid tile widget you can see that we have a widget with a header and a footer and this is created by the grid tile widget to make something like this you will use a sized box inside a center widget you will create your own height and width the child will be the grid tile and inside you can have a header which will use a simple container with the height 40. the child will be a center widget with the text header and the color will be black 38. after you can create a child widget in this example we will just use an image from Network and this is how it will look but you can also create a footer widget for this example we will use the same height the child will be a center with the text footer and the color will be also black 38 and now we can see on your screen you have created a grid tile widget the grid Tile Bar widget on the screen right now we use the grid tile widget but inside we use what we call the grid Tile Bar let me show you right now by creating a center and a size box widget with height and width inside the child we will have the grid tile the header will be a grid Tile Bar you can change the background color the leading will be a Nikon person the title will be text flutter map and the trailing will be a Nikon menu for the grid tile to work we need to create a child this one will just be an image Network and this is what we have on the screen right now you can also use the grid Tile Bar inside the footer for this example we use the background color and the leading so if you want to use the grid tile inside your flutter app you can use the grid Tile Bar inside the header and the footer this was how to use the grid Tile Bar Widget the animated rotation the first thing we need is a double call turns and we will set this one as 0. next inside a center column we will add the widget padding with the agent sets that all 50. the child will be the animated rotation the turns argument will be the turns that we have declared earlier the duration will be once again and the child will be a flutter logo with the size 100. under the padding in the column we will have an elevated button this one will have a child text rotate logo and the style will be colors dot orange accent finally we have the unpress and when we click on it this will trigger the set State and we'll say that the turns is equal to plus one quarter with all this when you press on the rotate logo button this will rotate the flutter logo one quarter and you can do it multiple time this is to create an animation for the rotation of any widget the e-row widget this one can be used to animate the transition between 2 widget in this example we have a Nikon which animate the transition inside another page with a different widget and this is created with the hero widget let me show you how it works first we'll create a list style inside we will have the trailing hero the tag will be tag one keep this in mind because we will reuse this later inside we have the child icon person and when we press on this it will trigger the navigator.push this will bring us to another page which will use the material page route and the Builder that will return the second page in other words this will bring us to another page the title of this list style will be text click on me but now it's time to create this second page we will create the class and return a scaffold widget inside we have the app bar second page the body will be a center with the column inside the children of the column we will have the hero Widget the tag will be the same as the previous one tag one and the child will be a container or range accent with the height and the width 100 and just like this when you press on the list style this will bring you to the other page and will animate the transition between the two Widget the icon and the container the ignore pointer widget as you can see on the screen I can click on the click me button but as soon as I click on this button I will block the click of the second one and this is because we use the ignore pointer to create something like this we'll start by using a Boolean ignore set to false in the center of the app we use a column widget and the children will be an elevated button inside we have the on press function that will trigger the set State and change the value of the ignore Boolean if it's false it will be true if it's true it will be false next the child is a text widget and if the value is true then it will be blocked otherwise it will be all good the style of the elevated button turn will also change we will use the elevated button.style from the primary color will be if it's true then it will be red otherwise green and you can see that every time I press on this button the color change but now it's time to use the ignore pointer the argument ignoring will be ignore which is our Boolean we have created the child will be an elevated button with the unpressed function and the child text click me if the value ignore is true then the button will not be clickable but if we change the value to false then the button will be clickable and this was how to use the ignore pointer with your flutter app the indexed stack widget if I click on different button this will change the image on the screen this is because we use the index stack widget to create something like this we will start with the int index equals zero inside the padding we will create a column widget and in the children we will start with a row the children inside the row will be first and then elevated button with the text zero it's the first button you can see on the screen the unpress will set State and set the index to zero this is the variable we created at the start we will create two other elevated button one that will set the index to 1 and 1 that will set the index to 2. in this way we can change the value of the index variable it's now time to create the indexed stack Widget the index argument will be the index variable we created the children will be three different image and now when we click the buttons to change the index this will automatically switch between these three widget this was how to use the index stack widget with your flutter app the list view widget this one is a way to display Multiple List style inside a scrollable list I will also show you how to create divider between each list style so let's start right now by using the list view that separated the item count will be 5. the item Builder will have the context and the index which will will return a list style because we use the dot separator you will need to create a separator Builder this one will have the context and the index you can create everything you need between each widget but for this example we will just use the divider widget with the color white and just like this you have used the list view widget the list style widget this is a box where you can display a leading a title and a trailing widget I will show you how to create this right now inside the center widget we will use the list style the title will be a text flutter map the tile color will be orange accent you can use untap function deleting will be a Nikon person and finally the trailing will be an icon menu the navigation bar widget this is what you will be able to create at the end of this video first thing first we will add a int current index and also a list which we will call Buddy of multiple icons with this we can go inside the scaffold widget and create a center Widget the child will be the body dot element at of the current Index this is the variable we created after this we will use the bottom navigation bar with the navigation bar widget this one will use the destinations and it will require multiple navigation destination the icon will be home and the label will be home if you put only one of them you will have a red screen so make sure that you have multiple navigation destination but now the button are not clickable to make this work you will need to use the selected index which will be the current index and then when you trigger the on destination select you will be able to set State and say that the current index is now equal to the index you just received with the on destination select and now you are able to change Pages inside your app with the navigation bar Widget the animated opacity widget you need to create a double opacity level that we will start by setting up at 1.0 inside a center and a column widget we will add the first widget which is the animated opacity this one will have the opacity of the opacity level that we have just created the duration of the animation will be 2 second the child will be a flutter logo with the size 50 and under this widget we will have the elevated button the child is a text saying fade logo and when we press on this we will set State and we will say that if the opacity level is currently zero then it will be 1 and otherwise it will be zero and with all this you can animate the opacity of the flutter logo you can see that it takes two seconds to vanish completely in the screen the stack widget on this example we have two image one over the other and this is because we use the stack widget in a center widget we will create the stack widget this one will take a list of children the first widget which will be under everything will be the center widget with an image asset ocean and now we will create another Center widget with the image asset blue.gpg and you can see that the other image will stack over the first one this was how to use the stack Widget the stepper widget this will create a step-by-step flow inside your app to make something like this we start by creating a variable current step set as 0 in a center widget we use the stepper widget with the step argument the first one will be a step the argument is active is a true or false Boolean and we will Define this by saying the current step is equal to zero if this is true you will see the information of the current step next you can create a title it will be step 1 and the content can be anything we will use a text with information for step one but now we will create two other step this one will be the step number two with a different logic and the step number three with also a different logic and now I will show you how to trigger those buttons first you will need to use the on step tab which gives you a new index with this you can set State and and set the current step to the new index now you can see that I can press on the other steps but nothing really happened this is because we need to set the current step to the variable current step now if I click you will see that the steps are changing after this we can use the on-step continue this will say if the current step is not the last one then you will move forward and go one step further we will also use the on step cancel and if it's not the first item then we will set State and go back from one item before so now you can click continue and cancel to go back but you can also change the type with the stepper type dot horizontal and this will give you an horizontal stepper Widget the stream Builder widget in this example new data are coming inside the application and every time we receive a new data the value will change we will start by creating a fake Firebase stream this one will be called the generate stream the first thing we will do inside is wait for twos again and then we will receive the value 1 then we will wait for once again and receive the value too later in this example I will show you what happened if we throw an error the third one will wait for once again and receive the value 3. now that we have created a fake Firebase stream we can put inside a center Widget the stream Builder the stream will be the generate stream that we just created the initial data will be zero and the Builder will have the context and the snapshot we will create a condition if the snapshot.connection state is equal to waiting then we will return a circular progress indicator if this SnapChat has an error then we will display a text error and otherwise we'll say a text snapshot.data Dot tostring and now if we refresh the application you will see that this will load for two second display the value 1 2 and 3. but now let's throw an error right after the value number two now I will refresh the app and you will see one and then the error this is because we have the condition if we have an error then display the text error the switch widget if you need a button just like this you can do it with the switch widget first we create a variable Boolean is Switched set as false in the center widget we create the switch Widget the value will be the Boolean is Switched and the unchanged will have the value which we will set State and set the is switch to the new value this will give you access to a switch Widget the tab page selector if you need to show the current page with dots like this at the bottom you can use the tab page selector widget first thing first we will create a list of widgets and inside we will put three different icon next we will need to use the width single ticker provider State mix in after we will create a controller and an index set as 0. in the init State we will set the controller to a tab controller the length will be the widgets dot length the initial index will be the current index value you will also need the vsync this which is accessible because we use this single tier provider State mix in because we use the controller we also need to dispose this controller with this we can go inside a scaffold widget create a stack widget with the alignment center inside the children we will use the tab bar view the controller will be the controller we just created the children will be the widgets which is a list of Icon then we need to create a positioned Widget the bottom will be 40. this is just the location for the tab page selector Widget the controller will also be the same controller the color will be black 38 and then we can create a floating action button which will use the Bottom bar this one will be used to change pages so inside the children we'll create a floating action button dot small the onpress will have a condition if it's not the last index then add one and change page otherwise reset everything and put the end text as zero then we will use the controller to animate into the next index with a knight icon the over elevation will be zero and the elevation 0 also and with all this you have created the tab page selector Widget the tab bar widget this is what you will be able to create with the tab bar Widget the first thing you need is a default tab controller you will set the number of item inside your tab bar the child will be a scaffold widget with the up bar inside we have the bottom and we will use the tab bar Widget the tabs argument will require three different tab the first one is home then setting then person after this we will also create a title with the text flutter map in the body of the scaffold we'll use the tab bar view the children will require three widget we will put a container or range accent home and now you see we have an error because we need to have three widgets the second one will be red accent with the icon setting and then orange accent with the person icon and now you have access to a tab bar widget inside flutter the page view widget this is what you will be able to create and to make this we will start with the page view widget inside we will use the children and we will create three different container one which will be orange with the text one one that will be red accent with the text 2 and one that will be blue gray with the text three and with only this code you will have something like this in your flutter app the positioned widget with this you will be able to display three different image one over the other but with different position let's start with a center widget then a stack Widget the children will be a position at widget inside we have the left 20 the top 20 and the child will be an image Network this will position the image 20 from the left and 20 from the top next we will create another position head with the left 60 and the top 120 and you can see that the position is coming from this information we will finally add another positioned with the left 100 and top 220 and this was how to use the position another widget with your flutter app the radio list style widget at the end this is what you will have on the screen and to create this we will start with a list of string called options the string current option will be option 0. the column will have multiple Widget the first one is the radio list style you can put a title which will be option one the value will be the option with the index 0. the group value will be the current option and the unchanged will return you the value that you can use to set State and set the current option to the new value this is pretty much the same thing as the radio button but already inside a list tile now we will create another one with the title option 2 the value option with the index 0 the value options with the index 1 group value current option and the unchange will set State and set the current option and like this you have created two radio list style the refresh indicator widget in this example I can refresh my list to have one more item inside let's create this right now with flutter first you will start with a list of item I would say item one and two and you will build the refresh indicator this one will have the on refresh which will be an async function the first thing we do is we will wait for once again and then we will Define the next item which will be the items that land plus one we will add this item inside the list of item we have and finally we will set State the child of the refresh indicator will be a list view dot Builder and if you want to change the color of the refresh indicator you can say color equal white and background color is equal to Orange accent this was the refresh indicator the rotated box widget on the screen we have the flutter logo which is rotated one quarter of a turn and you can do this by implementing the rotated box Widget the quarter turn argument will be one the child will be a flutter logo and this is what you will see on the screen if you change the quarter turn for two you will see the floral logo will turn even more this was the rotated box Widget the selectable text widget this will most likely be useful inside your flutter web app but you can put this in any app and to use this we will start with the center widget inside we will have the selectable text the first thing you need to add is the text then you can create also a style if you want there is an argument called the on selection changed and this will give you the information about the text selection you just did inside you can put any logic that you want and this was how to create a selectable text with flutter the slider widget if you need something like this in your app you can use the slider widget to build this we will start with a double current slider value at 20. the build will return the slider Widget the value will be the current slider value we just created Max is the maximum value of the slider and division is how many division you have in your slider the label will be the current slider value that round the tostring this is the value you can see on the screen when you move the slider the unchanged function will give you a new value which you can use to set State and set the new value of the current slider value to this value and this was how to create a slider Widget the snack bar widget when you press on this button this will display a snack bar and it will disappear automatically after a while and to create something like this we need to create first an elevated button with the text show snack bar the on press function will trigger the scaffold messenger that of context.show snack bar inside we will put the snack bar Widget the contents will be flutter map this is just the information inside the snack bar the action will be the snack bar action the label will be undo and the on press will be nothing for now but keep in mind that you can trigger anything when you press the undo button and just like this you can trigger a snack bar widget in your flutter app the visibility widget when I press on this button this will show and hide the image at the bottom we start with the is visible Boolean set as true in the center and the column widget we will create the children the first one is a text button when we press on this this will set State and change the Boolean value for the invert if it's true it will be false if it's false it will be true the child will be a text show and hide after this we create another Widget the image asset then a size at box 30 and finally we will use the visibility Widget the visible argument will use the variable Boolean we created and the child will be an image asset and now when you press on the button this will hide and show the image at the bottom the wrap widget this one is like a row but each element over the screen will go right under and to create this we start with the padding a center Widget the child will be a wrap the spacing will be 10 this is the space between each Widget the Run spacing will be 5 this is the additional space between each of them and the children will be a list that generate inside we will put 10 item and each of them will be a chip widget you can see that if I change the Run spacing for 50 and I save this will put a bigger space between each line of widget and this was the wrap widget this tape area widget on the application right now we have a text behind the status bar because we don't use the app bar but the safe area widget will make sure that this never happened and to use it the only thing you need is to wrap the text widget with the save area and now you can see that the text is right under the status bar this was the Safari Widget the layout Builder widget this one can be used to display different things inside your app depending on the size of the screen you can see that when the screen is under 600 this is what I see but if I move the screen on the side I will have an image so you can show different things on the app depending of the size of the screen to create something like this we will start with the layout Builder the Builder argument will have the context and the constraints and we will say if the constraints that Max width is bigger than 600 with then we will return a center widget with an image Network and otherwise we will return a center widget with the text screen under 600. with this you can see that when I move my screen to the other side it's over 600 so we can display the image Network the orientation Builder widget you can see on the screen right now this is a portrait mode but as soon as I turn the screen this is now landscape I will show you how to do this with your flutter app first we create a widget orientation Builder the Builder would have the context and the orientation and inside we will use a conditions if the orientation is equal to orientation.portrait then we will return a center widget with the text portrait otherwise we will return a center widget with the text landscape and just like that you have used the orientation Builder widget with your flutter app the Overflow bar widget this one is a mix between the row widget and the column widget I will show you how it works inside the padding we will create the Overflow bar the spacing will be all the spacing between each Widget the children will be an elevated button flutter map and we will create two other elevated button but now what will happen if we add another button in this case it will become a column widget so as soon as we don't have place on the screen anymore this will transform into a column Widget the fitted box widget whatever the size of this orange container the text will always fit inside perfectly and this is because we use the fitted box widget for this example we will create a container with height 25 with 100 color or range accent and the child will be a text widget this is a pretty long text we will also create a style of color black and without the fitted box widget this is what we'll see on the screen but if you wrap the text widget with the fitted box widget you will see that the text Will perfectly fit inside the con container and now let's try to remove the height and change the width for 300 this is what you will have on the screen you can see that whatever the size of the container the text will always be perfectly fit inside and this is because we use the fitted box widget the expansion tile widget and this is what you will have at the end to do something like this we will first create a Boolean custom icon set as false inside a column widget we will create the expansion tile the title will be a text expansion dial and you can also change the trailing icon if you want for this example we will say if the custom icon is true then display this one otherwise display the other icon later we will find a way to set State the custom icon to a new value inside the children you can add anything you want but we will create a list style Widget the title will be a random text on the Expansion change we will receive a new Boolean value we will use this one to set State and set the custom icon to the value expanded that we just received and with this you can see that the icon is now different when we click on the expansion but if you don't want to use a custom icon you can remove the trailing and it will still work with the basic icon the last thing I want to show you is you can use the control Affinity dot leading in order to change the location of this icon and this was how to create an expansion tile with flutter number 65 the Cupertino sliding segmented control you will see that you have a selection of multiple items and the segmented control will slide automatically with an animation to create this we will start with the end sliding equals 0 inside the center widget who will have the Cupertino sliding segmented control the children will be zero the text takes zero one text one and two text two so the children is a map next we need a group value and this is the sliding end that we have created next we have the unchanged value this will return us a new int value which we call the new value we will set State and say that the sliding is equal to the new value and just like this you have access to a Cupertino sliding segmented control with your flutter app this one is pretty cool if you want to discover more flutter widget you can click the playlist available on the screen thank you for watching make sure to subscribe and I see you in the next one bye
Info
Channel: Flutter Mapp
Views: 112,886
Rating: undefined out of 5
Keywords: Flutter, Top flutter widget, best flutter widgets, top 70 flutter widgets, the best flutter widgets, best 70 flutter widgets, flutter mapp, 70 flutter widgets, flutter widgets, best widgets flutter, top widgets flutter
Id: G1LGOH424lo
Channel Id: undefined
Length: 70min 6sec (4206 seconds)
Published: Mon Oct 10 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.