Flutter Simple Gravatar

Flutter Simple Gravatar:

In this tutorial, we are going to learn Flutter Simple Gravatar.

Do we have to know what is an avatar?

Gravatar is a globally recognized Avatar, An avatar is a graphical representation of a user. It could be the person’s picture or a random icon they want to associate with users profile. Most of the people would use icons for their identification purposes. it is very easy to identify a specific image to remember that a person name.

Creating Gravatar In Flutter:

Follow the below steps to create Gravatar in Flutter.

Add the dependency package:

To create Gravatar we need to add the dependency package to pubspec.yaml file. use the below code to add dependency package. After adding the dependency package run the get package method to import all the required files to the app.

 

dependencies:
simple_gravatar: ^1.0.4

Install the package:

You can install the gravatar package from the command line using the below code with Flutter as shown.

$ flutter packages get

Importing the Package:

After, Adding the dependency package to the pubspec.yaml file, you can now import the package into the dart code by using the below code. without adding the dependency package to the pubspec.yaml file if you import it will show package not found an error.

import 'package:simple_gravatar/simple_gravatar.dart';

Complete Example code for Flutter Gravatar:

Copy and Paste the below code into your main.dart file.

main.dart 

import 'package:simple_gravatar/simple_gravatar.dart';

void main() {
var gravatar = Gravatar('hello@example.com');
var url = gravatar.imageUrl(
size: 100,
defaultImage: GravatarImage.retro,
rating: GravatarRating.pg,
fileExtension: true,
);

print('Gravatar URL: $url');
print('Gravatar QR URL: ${gravatar.qrUrl()}');
print('Gravatar JSON URL: ${gravatar.jsonUrl()}');
}

Congratulations You Have Learned Flutter Gravatar….!!!

If It Is Helpful Share It With Your Friends….!!!

Leave a Reply

Categories