How can I change this default Icon in "BottomNavigationBarItem" flutter - flutter

[I want to change this default icon. How can I change this?]
BottomNavigationBarItem(
icon: Icon(
Icons.home,
size: 32,
),
label: "Tweets",
)

If you just want to change the icon with another one, you have to change the code here:
BottomNavigationBarItem(
icon: Icon(
Icons.anotherIconNameHere, // after the dot you change your icon
size: 32,
),
label: "Tweets", // here you can change the icon's label
)
Where I added anotherIconNameHere is where you will change your icon: after Icons. you can specify the icon you want to show. If you are using an IDE like Android Studio or Visual Studio Code, after typing the dot all the available icons will show up in a popover list.
You can check all the available icons of the Icons class here: Icons class - Material library - Dart API
In the material Icons class you can find pretty much all the icons you need.
Edited: In case you want to add custom icons or your icons, I strongly suggest you to read this article from Freecodecamp.org: FreeCodeCamp.Org - How to add custom icons to your flutter application
(If this was the answer you were looking for, remember to select it.)

#ashikur just use Image.asset to load local images. that you have to add in the asset folder and in pubspec.
BottomNavigationBarItem(
icon: Image.asset(
"assets/images/google.png"
),
label: "Tweets",
)

Related

How to generate QR code with logo, without overlapping QR codes in behind?

I dont want any QR codes hidden behind my logo. I want to generate QR with logo intially.
QrImage(
embeddedImage: const AssetImage('assets/images/444.png'),
embeddedImageStyle: QrEmbeddedImageStyle(
size: const Size.square(95),
),
backgroundColor: whiteColor,
data: widget.data!,
version: QrVersions.auto,
size: 200.0,
errorCorrectionLevel: QrErrorCorrectLevel.Q,
),
=====================================================
With this code, my QR code is hiding behind logo.
https://pub.dev/packages/qr_flutter hasn't been in active development recently.
You can use https://github.com/imrhk/qr.flutter as it contains some modifications in the original plugin including a property blendEmbeddedImage which originally comes from https://github.com/gibahjoe/qr.flutter
I have raised a PR on qr_flutter github repo but it hasn't been merged yet.

Flutter desktop windows notification badge on app icon

I can't seem to find this one. Is it possible to add the number on the app icon? (windows desktop)
For example this is Telegram on windows:
You can use package:windows_taskbar to add badge (overlay icon) to your Flutter Windows app's taskbar icon.
You have to create icons yourself though, maybe "1", "2", "3"... "9" & "9+" like most applications (as .ico files).
It's very easy to use as well.
Add in pubspec.yaml
dependencies:
windows_taskbar: ^1.1.0
Set Icon
WindowsTaskbar.setOverlayIcon(
ThumbnailToolbarAssetIcon('assets/red_slash.ico'),
tooltip: 'Stop',
);
Don't forget to add the icon file to your pubspec.yaml assets.
Remove Icon
WindowsTaskbar.resetOverlayIcon();
NOTE: I'm developer of the package.
These badges are autocreated on notification. There arent much packages for notifications in windows. You can give this a try.
quick_notify: ^0.2.1
QuickNotify.notify(
title: 'My title',
content: 'My content',
);

How to count the number of items in a section of the bottom navigation bar in flutter

I am developing a flutter application for a project of my studies. It is a click and collect application. I would like to add on the icon of the basket, the number of products inside, such as this :
I look a forum on internet but I didn't find anything, I find just a tuto for make a nav bar
Use Badge Package: Here
In this package you can add animation and much more...
You're looking for the Badge package.
Add as dependency via terminal
flutter pub add badges
Import and refer to docs for more customization.
import 'package:badges/badges.dart';
...
Badge(
badgeContent: const Text('Hello'),
child: const Icon(
Icons.abc
),
),
...

How to find flower and animal icons for flutter

I need flower and animal icons for an application. When I looked at Pub.dev, I couldn't find a package containing flower and animal icons. Can you give an idea about what I can do?
I looked at these packages but there are no flower and animal icons.
font_awesome_flutter: ^9.2.0
unicons: ^2.0.2
Material icons have some flower icons, but if you need something really specific you should use a SvgPicture, and download any SVG file.
Here is an example
SvgPicture.asset(
"assets/img/your-icon.svg",
height: 32,
width: 32,
color: Colors.black54,
),
To use this way you have to declare the assets folder in the pubspec.yaml and run a flutter pub get after that, an exampleenter code here:
flutter:
assets:
- assets/img/
Try using Flutter_Icons.
Add this in your Flutter page:
import 'package:flutter_icons/flutter_icons.dart';
IconButton(
icon: const Icon(FontAwesome5.cat), //Example
onPressed: () {},
)
And remember to add the package to your dependencies in your pubspec.yaml:
dependencies:
flutter_icons: ^1.1.0

Flutter icons do not show

I am trying to complete this Flutter Code Lab, but the icons do not appear in my application. But they appears in Android Studio code:
I have been included the lib in my file pubspec.yaml
name: startup_namer
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
english_words: ^3.1.0
But result is this:
My main.dart file looks like this:
// Add the heart icons to the ListView.
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
.....
Widget _buildRow(WordPair pair) {
final bool alreadySaved = _saved.contains(pair);
return new ListTile(
title: new Text(
pair.asPascalCase,
style: _biggerFont,
),
trailing: new Icon(
alreadySaved ? Icons.favorite : Icons.favorite_border,
color: alreadySaved ? Colors.red : null,
size: 22.0,
),
onTap: () {
setState(() {
if (alreadySaved) {
_saved.remove(pair);
} else {
_saved.add(pair);
}
});
},
);
}
}
I thought that is because I use iOS emulator, but when I tried with Android emulator the result was the same.
(Copied from the comments)
You need to set uses-material-design: true in pubspec.yaml for the icons to be included in the app.
In my case, I have written uses-material-design: true in pubspec.yaml file. I am able to solve this problem by restarting the Android emulator. You can also try by uninstalling old build from your emulator and then installing the new one.
This is little weird behavior, but it works for me.
Hot reloading does not show changes in resources. Press the stop button square red color in the top action menu bar of android studio and run the app again.
It works.
Please try:
Stopping the app
Running flutter clean in your app directory
Deleting the app from your simulator / emulator / device
Rebuild & Deploy the app.
If you are using the FlutterIcons library, make sure that your font-family in your pubspec.yaml matches the one declared in the my_flutter_app_icons.dart file.
I assume we're talking about the flutter_icons package?
I had to kill the app entirely and reinstall it and they started working for me. Not sure why a hot reload didn't do the trick.
Just delete the App from emulator/physical device on which you are working and again build the app.
It works for me and will surely works for you.
Add the following to your pubspec.yaml:
flutter:
uses-material-design: true
Took me a while to figure out based on the answers above that uses-material-design is a property of flutter, not of the root.
Icon changing to Chinese character was resolved by adding the correct path to the fonts folder. Specify, the correct path to your fonts folder by providing proper indentations:
Flutter Clean
Remove Build From your testing device/Emulator
Run the app
You need to set uses-material-design: true in pubspec.yaml for the icons to be included in the app.
Be sure to have a uses-material-design: true entry in the flutter section of your pubspec. yaml file. It allows you to use the predefined set of Material icons. Many Material Design widgets need to be inside of a MaterialApp to display properly, in order to inherit theme data.
this was issue for me
Make sure in pubspec.yaml file all the images and fonts have correct path and if you have added new image recently try to remove that and then rebuild
The icons were loading normally on all devices except android for me. To fix it I simply:
Before
Icon(
Icons.chevron_left,
size: 40.0,
color: Colors.white,
),
After
Icon(
MdiIcons.chevronLeft,
size: 40.0,
color: Colors.white,
),
Steps
Add to pubspec yahml
dependencies:
material_design_icons_flutter: ^4.0.5955
Add this to the file you want the icon
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
Instead of Icons.NameHere use MdiIcon.NameHere
if all the above not worked then run
flutter pub run flutter_launcher_icons:main
The problem started in my project when I included my app within GetMaterialApp instead of MaterialApp Widget. All Material icons started to look like [X].