Flutter Tutorial for Beginners #22 - Starting the World Time App

Net Ninja ยท Beginner ยท๐Ÿ› ๏ธ AI Tools & Apps ยท6y ago

About this lesson

Hey gang, in this Flutter tutorial we'll start our final, bigger project - the World Time app. ---------------------------------------- ๐Ÿฑโ€๐Ÿ’ป ๐Ÿฑโ€๐Ÿ’ป Course Links: Course files - https://github.com/iamshaunjp/flutter-beginners-tutorial Android Studio - https://developer.android.com/studio Git - https://git-scm.com/downloads Flutter Installation - https://flutter.dev/docs/get-started/install ๐Ÿฑโ€๐Ÿ’ป ๐Ÿฑโ€๐Ÿ’ป Other Related Courses: + Modern JavaScript Tutorial - https://www.udemy.com/modern-javascript-from-novice-to-ninja/?couponCode=NINJAYT

Full Transcript

okay then gang so I think we know enough about flotter now I've had enough practice with a couple of mini apps to attack the big project over this course and that is the world time app that I showed you at the very beginning of this playlist so close down any other project you've got going in Android studio at the moment and then click on start new flutter project flutter application click next and let's call this world underscore time and then we'll click Next and then give this a company domain then click on finish and it's going to create that boilerplate project for us okay so first things first I'm just going to go into the world time folder and I'm going to delete this test folder in the future I might do a whole series on testing inside flutter widget testing unit testing that kind of thing but for now it's kind of beyond the scope of this tutorial and all of our apps are quite small so we don't need testing too much at the moment so I'm going to delete that so it's not null hey and then inside main dots darts I'm going to delete all of the bumps that we get here all of the boilerplate code except for this bit at the top and then right here we'll use a material app instead and inside this material app ultimately we need a home property which is going to be some kind of widget that's going to show on the home screen now before we fill this in what I'd like to do is create a couple of different boilerplate widgets that are going to represent different screens in actual fact three because we're going to have three screens on this application in the past we've only ever used one which is on the home screen but in this one we're going to have a home screen which is the place that actually shows the time we're also going to have a loading screen while we get the data initially and we're also going to have a screen where a user can update the location and choose different place to find out the time so we need those three different pages or screens and what I'm going to do is go into the Lib folder and I'm going to create a new folder over here now you might not see the new directory or new folder option but you can go to new package as well that's basically just like a folder and we're going to call this pages and press ok so inside this folder we now need to make our dark files for the different pages and the reason I'm doing this is just so we don't have everything sitting directly inside live we just started to organize things a little better now because the apps getting a little larger so let me right click over here create some new files I'm gonna go to new doubt file and first of all we need the whole dart file and then if we expand this we can see that home file then I'm going to right click and I'm gonna go to new and new doubt file again this time I'm going to call it choose underscore location so this will be the widget in here that we have for the choose location screen and then finally we need one more so new again and then dart file and this is going to be called loading dots darts and that will be the initial loading screen when we first fire up the app it's going to show like a little spinner or something what are the data first loads and then when it does load it redirects to the home screen so what we need to do is just build up a few of these different widgets just the bare bones of them so what I'm going to do is copy this thing over here because we need the material dart library and I'm going to paste it in each of these first of all now I'm going to create a widget for the home screen a widget for the choose location screen and a widget for the loading screen so what I'll do for the home screen first of all is create a stateful widget because ultimately in the home screen we are going to be using state so I'm gonna say st and then ful and I'm gonna call this home so that creates us the stateful widget and it links a state object with that widget right here so inside the state object we had to build function where we return the widget to tree now at the minute this is just a container but ultimately we're going to return a scaffold here and inside the scaffold I'm gonna do a body property and for now what I'll do is just a text property as well that says home screen ok so if I now go to main darts and then say ok I want this now to be the whole widget that we just created over here then it's not going to work because it doesn't know what home is we need to import this file over here into this file so we can use it now to do that we could use a relative path so we could go into the pages folder and then get this home file right here and I'll show you that I could say imports and then it would be pages and then forward slash whole oops not in capitals whole darts and this would work you can see we no longer get the error now and if I was to save this I'm going to choose a device and then I'm going to preview this once the device loads so let's move this way over here and then let's preview this project so far ok and you can see that this all works we can see this home widget right here however what I'm going to do is show you a different way to import things like this and that is following a similar convention to this where we actually import some kind of package so what I'm going to do is replace this import over here with something else and that is going to be a package and then I'm going to do a colon and then it's the world time folder over here we can see that that's what we're going into then /pages then /home so now we're using this package import we don't actually have to specify the lib folder over here it knows to go into that then we're saying inside the pages folder then home dot darts so now if I save this it's gonna work exactly the same way and now what I'd like to do is just move this a bit down because currently this bar at the top that shows the time and the battery and things like that that is hiding where it says home screen so it's not really safe to put text up here right so what we could do is use a widget it's called safe area to move this down a bit now in the past we've not used this because we've always had an app bar at the top and that app bar kind of pushes the content down so we've not needed to use this safe area widget but now we're not using an app bar on the home page what I'd like to do is use that safe area widget so what I'll do is come to this text widget and I'm going to go to the action down and then rap with new widgets and this is going to be a safe area widget like so okay so now if we save this we can see that it brings it down into the safe area and that's what this widget does it moves the child of that widget down into a safe area on the screen where we can't actually see it not behind this little bar at the top okay so now we have this basic home screen let's move our attention to viewlets so in here we need to create a widget for choose location and again this is going to be a stateful widget in here because we're going to use data in the future to show these different locations so let's use the stateful snippet and we'll call this choose location like so okay so inside here we're just returning a container at the minute but instead let us return a scaffold as well and then inside that we need a body and then I'm just going to make this a text widget for now we don't need the safe area widgets in this screen because we ultimately going to be using an app bar at the top so it's going to bring the content down automatically but for now let's just add this text to say what screen this actually is so I'll say choose location screen and then we'll go to the next one which is the loading widget and this is going to be a stateful widget as well because we will be using changing state and data inside this widget in the future as well so let's create one last one stateful widget and we'll call this loading and then inside over here we're just returning a container at the minute instead let's return the scaffold again and inside the scaffold we'll do a body property and again this is just going to be a text widget for now to say loading screen okay so now we have all of our different pages set up we can just quickly test them by go to main dart and adding those widgets here and importing them here if we want to I'm not going to do that because it means we have to start messing around with the imports I think just trust me for now that we've created these widgets you can see there's nothing complex about them and they're ready and set up so that we can now navigate to them in the future when we need to so now we've got these basic different widgets set up in the next video what I'm going to show you is the basics of routing or routing in flutter apps and to do that we're also going to have to understand what maps are in Dart so we'll tackle that in the next video

Original Description

Hey gang, in this Flutter tutorial we'll start our final, bigger project - the World Time app. ---------------------------------------- ๐Ÿฑโ€๐Ÿ’ป ๐Ÿฑโ€๐Ÿ’ป Course Links: Course files - https://github.com/iamshaunjp/flutter-beginners-tutorial Android Studio - https://developer.android.com/studio Git - https://git-scm.com/downloads Flutter Installation - https://flutter.dev/docs/get-started/install ๐Ÿฑโ€๐Ÿ’ป ๐Ÿฑโ€๐Ÿ’ป Other Related Courses: + Modern JavaScript Tutorial - https://www.udemy.com/modern-javascript-from-novice-to-ninja/?couponCode=NINJAYT
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Playlist

Uploads from Net Ninja ยท Net Ninja ยท 0 of 60

โ† Previous Next โ†’
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

๐Ÿ“ฐ
From Apple Health Data to Clinical Storytelling: Building an AI-Powered Report with Python and Gemini
Learn to build an AI-powered report using Apple Health data and Python to create clinical storytelling with Gemini
Dev.to ยท Romina Elena Mendez Escobar
๐Ÿ“ฐ
Gemini Notebook: Vet Articles Before You Save
Use Gemini Notebook to vet articles before saving them to your knowledge base, saving time and increasing credibility
Medium ยท AI
๐Ÿ“ฐ
Claude HUD: Adding a Terminal Heads-Up Display to Claude Code
Add a terminal heads-up display to Claude code for improved observability and productivity
Dev.to AI
๐Ÿ“ฐ
AI Resume Generator That Gets Shortlisted
Learn how to automate resume generation using AI to save time and increase chances of getting shortlisted
Dev.to ยท Amrendra N Mishra
Up next
Schedule Python Scripts in the Cloud for FREE
Thomas Janssen
Watch โ†’