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

ScrollController not attached to any scroll views. #206

Open
Zazo032 opened this issue Aug 4, 2022 · 1 comment
Open

ScrollController not attached to any scroll views. #206

Zazo032 opened this issue Aug 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Zazo032
Copy link
Contributor

Zazo032 commented Aug 4, 2022

Version

2.5.0

Library

feedback

Flutter channel

stable

Flutter version

3.0.5

Platform

Android

Details

When trying to open a custom Feedback widget, I'm seeing the following logs:

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
ScrollController not attached to any scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 107 pos 12: '_positions.isNotEmpty'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:107:12)
#3      _DraggableScrollableSheetScrollController.position (package:flutter/src/widgets/draggable_scrollable_sheet.dart:750:13)
#4      _DraggableScrollableSheetState._replaceExtent.<anonymous closure> (package:flutter/src/widgets/draggable_scrollable_sheet.dart:681:27)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1091:9)
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:997:5)
#11     _invoke (dart:ui/hooks.dart:151:10)
#12     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#13     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 5 frames from class _AssertionError and dart:async)
====================================================================================================

We're not using any scroll controller in the custom view, so I'm not really sure why there's a scroll controller attached there, or how to just ignore it (we don't need scroll for our custom feedback provider)

Steps to reproduce

Add the BetterFeedback widget like this:

class SampleApp extends StatelessWidget {
  return MultiBlocProvider(
    ...
    child: BetterFeedback(
      feedbackBuilder: (BuildContext context, OnSubmit onSubmit, _) {
        return FeedbackWidget(onSubmit: onSubmit);
      },
      localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
        AppLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
      ],
      child: MaterialApp(...),
    ),
  );
}

And add a custom feedback provider like this:

class FeedbackWidget extends StatefulWidget {
  const FeedbackWidget({
    required this.onSubmit,
    super.key,
  });

  final OnSubmit onSubmit;

  @override
  State<FeedbackWidget> createState() => _FeedbackWidgetState();
}

class _FeedbackWidgetState extends State<FeedbackWidget> {
  late AppLocalizations l10n;
  late TextEditingController _controller;

  @override
  void initState() {
    super.initState();
    _controller = TextEditingController();
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    l10n = context.l10n;
  }

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

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: <Widget>[
        Flexible(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16),
            child: TextField(
              controller: _controller,
              decoration: InputDecoration(
                label: Text(l10n.feedbackInputLabel),
                border: const OutlineInputBorder(),
              ),
            ),
          ),
        ),
        OutlinedButton(
          label: l10n.actionSubmit,
          onPressed: () => widget.onSubmit(_controller.text),
        ),
      ],
    );
  }
}

Output of flutter doctor -v

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Versi¢n 10.0.22000.832], locale es-ES)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.68.1)
[√] Connected device (3 available)
[√] HTTP Host Availability

• No issues found!
@Zazo032 Zazo032 added the bug Something isn't working label Aug 4, 2022
@Zazo032
Copy link
Contributor Author

Zazo032 commented Aug 4, 2022

Just saw you can avoid that error by setting this:

BetterFeedback(
  theme: FeedbackThemeData(
    sheetIsDraggable: false,
  ),
),

But I didn't find anything in the docs for that, so maybe docs can be improved for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant