flutter-clutter / svg-to-flutter-path-converter

Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves.
56 stars 19 forks source link

ReferenceError: width is not defined #5

Open m7mdra opened 2 years ago

m7mdra commented 2 years ago

Hi

When i run the following command

svg-to-flutter convert Downloads/ic_mail.svg -o path.dart

i get this error

/Users/user1/svg-to-flutter-path-converter/src/convert.js:252
  let pathData = getPathData(shapes, width, height);
                                     ^
ReferenceError: width is not defined
    at shapesToFlutterCodeConverter (/Users/user1/svg-to-flutter-path-converter/src/convert.js:252:38)
    at SvgToFlutterPathConverter.convertFromString (/Users/user1/svg-to-flutter-path-converter/src/convert.js:54:12)
    at SvgToFlutterPathConverter.convertFromFilePath (/Users/user1/svg-to-flutter-path-converter/src/convert.js:26:17)
    at Command.<anonymous> (/Users/user1/svg-to-flutter-path-converter/src/index.js:24:35)
    at Command.listener [as _actionHandler] (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:481:17)
    at /Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1237:65
    at Command._chainOrCall (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1153:12)
    at Command._parseCommand (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1237:27)
    at Command._dispatchSubcommand (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1059:25)
    at Command._parseCommand (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1202:19)

Node.js v18.3.0

i tried with a big svg then thought size might be an issue or file included tags unknown..etc, then i tried with a smaller svg you will find it below

email

Thanks in advance.

flutter-clutter commented 2 years ago

Hi @m7mdra. I fixed it in the latest commit. Can you pull and try again, please? :)

m7mdra commented 2 years ago

Hey @flutter-clutter, thanks for following up

its working now,

However i tried it with different image with more details, curves, color. it produced the following error.


/Users/user1/svg-to-flutter-path-converter/src/convert.js:223
  return (value.match(/\d+/g)).map(function (o) {
                               ^

TypeError: Cannot read properties of null (reading 'map')
    at colorStringToObject (/Users/user1/svg-to-flutter-path-converter/src/convert.js:223:32)
    at /Users/user1/svg-to-flutter-path-converter/src/convert.js:319:17
    at Array.forEach (<anonymous>)
    at shapesToFlutterCodeConverter (/Users/user1/svg-to-flutter-path-converter/src/convert.js:254:18)
    at SvgToFlutterPathConverter.convertFromString (/Users/user1/svg-to-flutter-path-converter/src/convert.js:54:12)
    at SvgToFlutterPathConverter.convertFromFilePath (/Users/user1/svg-to-flutter-path-converter/src/convert.js:26:17)
    at Command.<anonymous> (/Users/user1/svg-to-flutter-path-converter/src/index.js:24:35)
    at Command.listener [as _actionHandler] (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:481:17)
    at /Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1237:65
    at Command._chainOrCall (/Users/user1/svg-to-flutter-path-converter/node_modules/commander/lib/command.js:1153:12)

this is the image used.

shape1

Thanks in advance.

usman-whizpool commented 1 year ago

hey, facing same error as above

Screenshot 2022-09-29 at 11 41 01 AM
eokdev commented 9 months ago

hey, facing same error as above Screenshot 2022-09-29 at 11 41 01 AM