M Al-Haroon
 · Managing director at Payspin

Creating Avatar Image

Widgets & Design

Hello FlutterFlow Community,
Is there an easy way to create cartoon avatar images? I was trying to create cartoon avatars using the avatar_plus: ^0.0.5 package, but the code didn’t work as expected. I was trying to return my custom action as an image path, but instead, my code was returning a raw SVG image string.

Here is my code for returning the image path:

// Automatic FlutterFlow imports

import '/backend/backend.dart';

import '/backend/schema/structs/index.dart';

import '/actions/actions.dart' as action_blocks;

import '/flutter_flow/flutter_flow_theme.dart';

import '/flutter_flow/flutter_flow_util.dart';

import '/custom_code/actions/index.dart'; // Imports other custom actions

import '/flutter_flow/custom_functions.dart'; // Imports custom functions

import 'package:flutter/material.dart';

// Begin custom action code

// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:avatar_plus/avatar_plus.dart';

Future<String> generateAvatar(String name) async {

// Generate SVG string for the avatar

final String svgCode = AvatarPlusGen.instance.generate(name);

return svgCode;

}

Also, if anyone knows how I can modify this code to return an image path instead of a raw SVG image string, I would appreciate the help!

What have you tried so far?

creating Custom Action listed Above

Did you check FlutterFlow's Documentation for this topic?
Yes
3
3 replies