psk907 / fluttermoji

A light-weight and highly customizable SVG graphic set for Flutter which generates avatars and provides a Customizer Widget, personalized CircleAvatar and other utility functions.
https://pub.dev/packages/fluttermoji
MIT License
72 stars 50 forks source link

Avatar not being updated | Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast #19

Open RodrickVy opened 2 years ago

RodrickVy commented 2 years ago

The "_getFluttermojiProperty()" method in FluttermojiController is throwing a CastError, this happens when getting the emoji options, the first click to add a property to the avatar, so the FluttermojiCircleAvatar keeps showing the indicator, I tried to see whether it could my issue, but closely followed your example on the pub. dev.

I have both the FluttermojiCircleAvatar, The customizer and the save widget on one page, and added the controller to dependency injection, I think this is something to look into. I like the simplicity of this plugin. Thanks for the work! _ Attached is an image of the stack, Thanks.

svnty commented 9 months ago

same problem

Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
Another exception was thrown: type 'Null' is not a subtype of type 'int' in type cast
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast
#0      FluttermojiController._getFluttermojiProperty (package:fluttermoji/fluttermojiController.dart:77:42)
#1      FluttermojiController.getFluttermojiFromOptions (package:fluttermoji/fluttermojiController.dart:101:26)
#2      FluttermojiController.setFluttermoji (package:fluttermoji/fluttermojiController.dart:88:24)
#3      FluttermojiSaveWidget.build.<anonymous closure> (package:fluttermoji/fluttermojiSaveWidget.dart:56:37)
#4      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1183:21)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
#6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:652:11)
#7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:309:5)
#8      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:242:7)
#9      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:630:9)
#10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
#11     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
#12     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#13     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
#14     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#15     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:488:19)
#16     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:468:22)
#17     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:439:11)
#18     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:413:7)
#19     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
#20     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
#21     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
#22     _invoke1 (dart:ui/hooks.dart:328:13)
#23     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:410:7)
#24     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)

My code

  @override
  Widget build(BuildContext context) {
    var _width = MediaQuery.of(context).size.width;
    return Center(
      child: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 30),
              child: FluttermojiCircleAvatar(
                radius: 100,
                backgroundColor: Colors.grey[200],
              ),
            ),
            SizedBox(
              width: min(600, _width * 0.85),
              child: Row(
                children: [
                  Text(
                    "Customize:",
                    style: Theme.of(context).textTheme.titleLarge,
                  ),
                  Spacer(),
                  FluttermojiSaveWidget(),
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 30),
              child: FluttermojiCustomizer(
                scaffoldWidth: min(600, _width * 0.85),
                autosave: false,
                theme: FluttermojiThemeData(boxDecoration: BoxDecoration(boxShadow: [BoxShadow()])),
              ),
            ),
          ],
        ),
      ),
    );
}

Flutter doctor

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.86.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!