Skip to content

visibility_detector 0.3.0 breaks the build #354

@alexeyinkin

Description

@alexeyinkin

Steps to reproduce

  1. In Android Studio, create a new Flutter project.
  2. Add visibility_detector: ^0.3.0 to pubspec.yaml
  3. Replace main.dart with the following:
import 'package:flutter/material.dart';
import 'package:visibility_detector/visibility_detector.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: VisibilityDetector(
        key: ValueKey(1),
        child: Scaffold(),
        onVisibilityChanged: (_) {},
      ),
    );
  }
}

Expected behavior

The app builds.

Actual behavior

Launching lib/main.dart on SM T585 in debug mode...
Running Gradle task 'assembleDebug'...
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.3.0/lib/src/visibility_detector_layer.dart:126:37: Error: Property 'renderView' cannot be accessed on 'RendererBinding?' because it is potentially null.
 - 'RendererBinding' is from 'package:flutter/src/rendering/binding.dart' ('../../../snap/flutter/common/flutter/packages/flutter/lib/src/rendering/binding.dart').
Try accessing using ?. instead.
    assert(RendererBinding.instance.renderView != null);
                                    ^^^^^^^^^^
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.3.0/lib/src/visibility_detector_layer.dart:127:59: Error: Property 'renderView' cannot be accessed on 'RendererBinding?' because it is potentially null.
 - 'RendererBinding' is from 'package:flutter/src/rendering/binding.dart' ('../../../snap/flutter/common/flutter/packages/flutter/lib/src/rendering/binding.dart').
Try accessing using ?. instead.
    var clipRect = Offset.zero & RendererBinding.instance.renderView.size;
                                                          ^^^^^^^^^^
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.3.0/lib/src/visibility_detector_layer.dart:170:35: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.
 - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../snap/flutter/common/flutter/packages/flutter/lib/src/scheduler/binding.dart').
Try calling using ?. instead.
        SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
                                  ^^^^^^^^^^^^^^^^^^^^
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/visibility_detector-0.3.0/lib/src/visibility_detector_layer.dart:194:10: Error: Method 'scheduleTask' cannot be called on 'SchedulerBinding?' because it is potentially null.
 - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../snap/flutter/common/flutter/packages/flutter/lib/src/scheduler/binding.dart').
Try calling using ?. instead.
        .scheduleTask<void>(_processCallbacks, Priority.touch);
         ^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script '/home/alexey/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/alexey/snap/flutter/common/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s
Exception: Gradle task assembleDebug failed with exit code 1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions