![]() Let’s say you’re developing for Android and you want to create a custom background color for your icon that is also transparent. To do this, we can experiment with a few more properties that belong to flutter_launcher_icons. Adding a custom background to your Flutter icon Now, let’s try to make our icons a bit more interesting. Samsung Galaxy Tab A 8”, Android 11 iPad (6th Generation), iOS 15.4.1Īs you can see, the two icon layouts look different based on the operating system and physical device, but our icon is reflected correctly! This is a great start. Here is our app with its new launcher icon. If this worked correctly, the default Flutter icon should be replaced with your specified icon. Then, you can exit the app and see what the app icon looks like. To do this, run the app on whatever simulator or device you’d like to use and wait for it to open. Now we can try to see if our icons are reflected on their respective platforms. Perfect! It looks like there are no outstanding issues. Now that we have that in place, let’s run flutter_clean, then re-rerun flutter pub get & flutter pub run flutter_launcher_icons:main. It would appear that the solution is depending directly on a forked Git repo and branch of flutter_launcher_icons. ![]() Here, we are referencing the Git repository for the package directly, as well as a specific commit, branch, or tag. We can do this by adding the below code to pubspec.yaml under dependencies. The workaround is to directly depend on the package by referencing the Git repository. If you’re still planning on using 0.9.2, I found a solution here. If for whatever reason you’re unable to upgrade to 0.9.3 then continue reading about the workaround. N.B., flutter_launcher_icons released a new version in June 2022 (0.9.3) that appears to incorporate the solution I will outline below. It looks like the issue appears to be related to minSdkVersion, which basically specifies a minimum Android SDK version needed to work with the package. It would appear that there might be an issue with conflicting Flutter versions and the latest version of flutter_launcher_icons (0.9.2). I followed the README and tried to follow this tutorial, cleared cache, etc. This is the issue I mentioned earlier, and this stumped me for a while. But for some reason, when I got the below error. Normally, this is fine, and for some of you, this will be sufficient. If you follow the instructions under the installation on pub.dev, you will see it tells you to reference the latest version. flutter pub run flutter_launcher_icons:main Now you can run flutter pub get to get and update all mentioned dependencies in pubspec.yaml. Put the below code into pubspec.yaml to start. Otherwise, set true to default to image_path (I ran into an issue here too. iOS: this is where you can specify a different file for iOS.Otherwise, put true to default to image_path Android: this is where you can specify a different file for Android.Image_path: this is where you include a reference to /assets/icon.png.Underneath this property, you will have three properties: image_path, android, and ios. Next, you will need to add the flutter_icons property to pubspec.yaml just above dev_dependencies. There is a slight issue here that I will get to in a moment. The next thing you need to do is head over to your pubspec.yaml file, and, under dependencies, add flutter_launcher_icons. After you’ve created your assets directory, move your icon image into it. Now that you have an image, create a directory in your Flutter app called assets if you do not have one already. When you make your own, use a 1:1 ratio (mine is 714×714), as this will ensure your icon looks best and most evenly centered. I pulled a heart icon (included on GitHub) from Google Images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |