The first part of your app that a user interacts with is the app icon. In this video learn how to import an icon into your Flutter project.
- [Instructor] All right, so, now that we've pretty much created all of the interface of our I Am Rich app, we have a scaffold with a app bar, a body, an image that comes from our assets in our Images folder, but there's just one thing that we still haven't got. We haven't got a custom app icon. For every single app that you create using Flutter, you get a default Flutter logo as your app icon. Now, if you start creating lots of apps, it can get very confusing, very quickly. And besides, when you're uploading it to the App Store you don't want it to look like a default Flutter app, right? So, how do we give our apps an app icon? Now, first thing's first, I want you to go ahead and download the I Am Rich app icon from this current lesson. There's a file that you can download, and once you've downloaded it, and open it, you should see an image that looks something like this. And then, what you're going to do is you're going to go to a website called appicon.co, and you're going to drag and drop your image, that's pretty large, into the placeholder there, and then we're going to select for all the platforms that we want to create an app icon for. So, we're going to uncheck iPad, Watch, and Mac, and we're only going to generate icons for the iPhone and Android. Go ahead and click Generate, and you should be able to download a zipped file that contains all of the icons that they've generated for you. If you have a peek inside here, you can see inside Android we've got some folders that contain different sized icons. So, for example, this one is the smallest, and this one is the largest Android icon. And it's done the same for iOS as well, and it's inside the Assets.xcassets folder. The next thing we have to do is to actually move these assets into our current project. And to do that we're going to need the project navigator over here. So, remember I said that we have our iOS folder which contains all the files of our iOS app, and our Android folder that contains all the files of our Android app. And these files include the actual launcher icon, or the app icon, if you will. So, let's first start with the Android app. If you go into the app folder, then you go into source, then you go into main, and finally you go into res, you can see that we've got a whole bunch of folders here, and all of these that start with a mipmap are your app icon folders. So, if you select the res folder, right-click, and open Reveal in Finder, it will locate that folder for you. And if you're working on Windows, then when you right-click on the folder, you should find something that says Show in Explorer, which is the equivalent of Finder on Windows. But once we've got that folder found and we can open it up, we can have it side by side with the downloads that we had from the appicon.co website. And we open up the Android folder, you can see that there's a couple of files that look pretty the same as over here, right? We've got a lot of mipmap folders. So, what I want you to do is to select everything inside the res folder that says mipmap, and you're going to move it into your Trash. Now, instead, you're going to select all the ones that came from your Android folder, your download off of the app icon website, and you're going to drag it in. And now, that adds all of the app icons that were generated from our website into our project. So, we're done with our Android project, and we can collapse it. So, onto the iOS project. Now, inside the iOS folder, we're going to open up the folder that's called Runner, not Runner.xcoproject, not Runner.xcoworkspace, but the actual Runner folder. And here, we have something called Assets.xcassets, which is where our app icons actually live. And you can see that at the moment the different resolutions of the Flutter default icon. So, let's change that. We're going to right-click on the Assets.xcassets folder, and we're going to again Reveal in Finder, or Show in Explorer. And we're going to have our windows side by side again, and on the left the Runner is, of course, our iOS app, and on the right we've got the images from our app icons download. And then, we're going to delete the Assets.xcassets folder from our Runner over here. So, we're just going to drag that again to Trash, or Command + Backspace to delete. And then, I'm going to drag the same one from the downloaded file into here. And if you've done everything that I've just said, we should now have app icons for both our iOS and Android app. I'm going to go ahead and launch my Android Emulator. So, now I'm going to make sure I've got my Android Emulator selected, and I'm going to go ahead and click Run. And we now have our app showing up on our Android phone, and if I click on the Home button, and drag up to show all of my apps, you can see that we've got our I Am Rich app right here with the custom icon. Now, if you're an Android user, you might've noticed that within the past few years Google has pretty dramatically changed the styling of the app icons. What used to be square icons with transparencies and different shapes has now been pretty much unified into these circular icons. And you can see with our I Am Rich icon, even though we're providing the right-sized assets for the app icon, it gets this white circle around it, which some of you may or may not like. And in the wild, I've seen some app designers deciding to go along with this style, but others have decided to embrace the circular icon. So, I want to quickly show you how you can do this also. Inside our project folder, if we expand the Android folder, and we go to app, source, main, then we're going to right-click on the res folder, going to click on New, and we're going to select Image Asset. And then, we get into our Image Asset configuration wizard, and we get to pick a Path, or namely the starting image. I'm going to go ahead and pick our I Am Rich app icon, and I'm going to click on Open. And then, it's going to show you your icon in all sorts of different configurations, square, rounded square, squircle, circle, et cetera. And what you can do is you can resize the image so that it fits into the space that you want it to be seen in. If you're going for your round icon, or your legacy icon, you can see in all of these scenarios it still looks good, the diamond is still within the circle. So, once you're done adjusting, go ahead and click Next, and then it's going to replace all of the places we had our previous images with the new ones, it's going to be overwritten by this, and that's exactly what we want, so, go ahead and click Finish. And now, it's added the files that we've edited, and we can go ahead and Run our app again. Now that our app has started again, I'm going to click on the Home button, and when we drag up our menu, you can see our new icon fills the entire space of the circle. And to my eyes, at least, I think that looks a lot better. It's up to you which style you want to choose. You can go for sort of like the calculator app, the calendar app style, where you've got your square icon with in a circle, or you can fill up the entire circle with your design. But these are the two ways that you can incorporate your Android app icon. And if I Run the app on the iPhone, you can see that my app icon has also updated to the one that I want. So, this is a really easy way of updating your Android and iOS app icons. And if you want different app icons, then you can simply use a different image and only generate the iPhone sets, or only generate the Android sets, and replace them as you need to. So, this has been pretty fun. We've built an app complete with an app icon, with image assets, and all the good parts of any mobile app. So, now all we have to do is to run it on a physical device. For all of that, and more, I'll see you on the next lesson.
This course was created by London App Brewery. We are pleased to host this content in our library.