Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passed decoration shape is ignored #67

Closed
silverhairs opened this issue Aug 23, 2023 · 1 comment · Fixed by #75
Closed

Passed decoration shape is ignored #67

silverhairs opened this issue Aug 23, 2023 · 1 comment · Fixed by #75
Assignees

Comments

@silverhairs
Copy link

silverhairs commented Aug 23, 2023

Currently the SuperTooltip class takes a decoration field just like a Tooltip class but the shape field inside that decoration is completely ignored. I would suggest either to hide it or to use it to override the default shape cause it's a bit confusing, for example I spent the last 2hours thinking that there was an issue with my custom painter just to realize that it was being completely ignored by the SuperTooltip class.

Code snippet to reproduce

class CustomTooltip extends StatefulWidget {
  const CustomTooltip({required this.child, super.key});

  final Widget child;

  @override
State<CustomTooltip> createState() => _CustomTolltipState();
}

class _CustomTolltipState extends State<CustomTooltip> {
  final _controller = SuperTooltipController();

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      Future.delayed(const Duration(seconds: 1), _controller.showTooltip);
    });
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return SuperTooltip(
      showBarrier: false,
      borderRadius: 8,
      bottom: 5,
      hasShadow: false,
      popupDirection: TooltipDirection.up,
      borderColor: Colors.teal[700]!,
      showCloseButton: ShowCloseButton.none,
      backgroundColor: Colors.teal[700],
      content: ConstrainedBox(
        constraints: const BoxConstraints(maxWidth: Spacing.s52),
        child: Row(
          children: [
            Expanded(
              child: Text(
                'Example',
                style: context.textTheme.labelLarge?.copyWith(
                  color: Colors.white,
                ),
              ),
            ),
            SizedBox.square(
              dimension: Spacing.s8,
              child: IconButton(
                iconSize: Spacing.s4,
                onPressed: () {},
                icon: const Icon(
                  Icons.close,
                  color: Colors.white,
                ),
              ),
            )
          ],
        ),
      ),
      controller: _controller,
      decoration: const ShapeDecoration(
        shape: CustomShape(),
      ),
      child: widget.child,
    );
  }
}

class CustomShape extends ShapeBorder {
  const CustomShape();

  @override
  EdgeInsetsGeometry get dimensions =>
      const EdgeInsets.only(bottom: Spacing.s10);

  @override
  Path getInnerPath(Rect rect, {TextDirection? textDirection}) => Path();

  @override
  Path getOuterPath(Rect rect, {TextDirection? textDirection}) {
    return Path()
      ..addRRect(
        RRect.fromRectAndRadius(rect, const Radius.circular(8)),
      )
      ..moveTo(rect.bottomCenter.dx - 15, rect.bottomCenter.dy)
      ..relativeArcToPoint(
        Offset(rect.bottomCenter.dx - 4, rect.bottomCenter.dy),
        radius: const Radius.circular(100),
      )
      // ..moveTo(rect.bottomCenter.dx, rect.bottomCenter.dy)
      ..relativeLineTo(10, 20)
      ..relativeArcToPoint(
        Offset(rect.bottomCenter.dx - 4, rect.bottomCenter.dy),
        radius: const Radius.circular(100),
      )
      ..relativeLineTo(10, -20)
      ..close();
  }

  @override
  void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) {}

  @override
  ShapeBorder scale(double t) => this;
}
Flutter Doctor
[!] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-arm64, locale en-DE)
  • Flutter version 3.10.6 on channel stable at /Users/silverhairs/fvm/versions/3.10.6
  ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.0/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/silverhairs/fvm/versions/3.10.6. Consider adding /Users/silverhairs/fvm/versions/3.10.6/bin to the front of your path.
  • Upstream repository https://github.com/flutter/flutter.git
  • Framework revision f468f3366c (6 weeks ago), 2023-07-12 15:19:05 -0700
  • Engine revision cdbeda788a
  • Dart version 3.0.6
  • DevTools version 2.23.1
  • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
  • Android SDK at /Users/silverhairs/Library/Android/sdk
  • Platform android-33, build-tools 33.0.2
  • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
  • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
  • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
  • Xcode at /Applications/Xcode.app/Contents/Developer
  • Build 14E300c
  • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
  • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
  • Android Studio at /Applications/Android Studio.app/Contents
  • Flutter plugin can be installed from:
    🔨 https://plugins.jetbrains.com/plugin/9212-flutter
  • Dart plugin can be installed from:
    🔨 https://plugins.jetbrains.com/plugin/6351-dart
  • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.81.1)
  • VS Code at /Applications/Visual Studio Code.app/Contents
  • Flutter extension version 3.70.0

[✓] Connected device (4 available)
  • sdk gphone64 arm64 (mobile) • emulator-5554             • android-arm64  • Android 13 (API 33) (emulator)
  • iPhone (mobile)             • 00008101-00120D212EFA001E • ios            • iOS 16.6 20G75
  • macOS (desktop)             • macos                     • darwin-arm64   • macOS 13.4.1 22F770820d darwin-arm64
  • Chrome (web)                • chrome                    • web-javascript • Google Chrome 116.0.5845.96
  ! Error: iPhone is busy: Making iPhone ready for development. Xcode will continue when iPhone is finished. (code -10)

[✓] Network resources
  • All expected network resources are available.

! Doctor found issues in 1 category.
@silverhairs silverhairs changed the title Cannot pass in custom shape. Passed decoration shape is ignored Aug 23, 2023
@bensonarafat
Copy link
Owner

@silverhairs
Thanks for this.
I'll work on it

@bensonarafat bensonarafat self-assigned this Aug 23, 2023
This was referenced Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants