Skip to content

Line (drawn using canvas.drawPoints()) placed above an interactive viewer disappears partially when a widget is placed above it  #106793

@SheenaJacob

Description

@SheenaJacob

Steps to Reproduce

The issue was previously described in #106187 and was closed as it didn't have a problem on the master branch. The current code includes the addition of the line being placed on top of an interactive viewer and has also been tested on the master branch.

  1. Execute flutter run on the code sample
  2. Tap on the TextField and hover the mouse on the screen

Expected results: Line below the text field should remain the same length and not get cut off on hovering above it.

Actual results: Part of the line below disappears from time to time when clicking the text box and hovering the mouse over the screen.

Code sample
import 'dart:ui';

import 'package:flutter/material.dart';

void main() async {
  runApp(const MaterialApp(
      debugShowCheckedModeBanner: false, home: DistanceProvider()));
}

class DistanceProvider extends StatelessWidget {
  const DistanceProvider({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // Finds the center of the screen
    final width = MediaQuery.of(context).size.width / 2;
    final height = MediaQuery.of(context).size.height / 2;

    return Scaffold(
      body: InteractiveViewer(
        child: Stack(
          children: [
            // Draws a line using the Custom painter at the center of the screen (width :400 px)
            CustomPaint(
              size: Size.infinite,
              painter: _DrawPath(
                offsetPoints: [
                  Offset(width - 200, height),
                  Offset(width + 200, height)
                ],
              ),
            ),
            // Places a text box to enter the distance between the two points
            Center(
              child: Container(
                width: 50,
                decoration: const BoxDecoration(color: Colors.white),
                child: TextField(
                  onChanged: (String value) {},
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

///Creates a path by drawing a line from one consecutive point to the next
class _DrawPath extends CustomPainter {
  _DrawPath({
    required this.offsetPoints,
  });

  final List<Offset> offsetPoints;

  @override
  void paint(Canvas canvas, Size size) {
    canvas.drawPoints(PointMode.polygon, offsetPoints, Paint());
  }

  @override
  bool shouldRepaint(_DrawPath oldDelegate) => true;
}
Logs

Analyzing disappearing_line_bug...
No issues found! (ran in 3.6s)

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.3, on macOS 12.4 21F79 darwin-x64, locale en-DE)
• Flutter version 3.0.3 at /Users/jshe/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 676cefa (7 days ago), 2022-06-22 11:34:49 -0700
• Engine revision ffe7b86a1e
• Dart version 2.17.5
• DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jshe/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3

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

[✓] Android Studio (version 4.2)
• 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.8+10-b944.6916264)

[✓] VS Code (version 1.57.0)
• VS Code at /Users/jshe/Downloads/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.53

[✓] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopf: material designflutter/packages/flutter/material repository.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions