akvelon / flutter-code-editor

Flutter Code Editor is a multi-platform code editor supporting syntax highlighting, code blocks folding, autocompletion, read-only code blocks, hiding specific code blocks, themes, and more.
https://akvelon.com
Apache License 2.0
212 stars 52 forks source link

Version 0.2.10 breaks ScrollController #184

Open stefalda opened 1 year ago

stefalda commented 1 year ago

Hi, as soon as I've updated to latest version from 0.2.9 I've got this erro the first time the parent widget build (you have to restart the app to reproduce the error):

Launching lib/main.dart on macOS in debug mode...
main.dart:1
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-000410223AE2801E }
{ platform:macOS, arch:x86_64, id:00006000-000410223AE2801E }
Connecting to VM Service at ws://127.0.0.1:59983/BYeQVq4jVsU=/ws

════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for CodeController:
ScrollController not attached to any scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
scroll_controller.dart:1
Failed assertion: line 107 pos 12: '_positions.isNotEmpty'

2

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
scroll_controller.dart:107
#3      ScrollController.offset
scroll_controller.dart:115
#4      _CodeFieldState._getPopupLeftOffset
code_field.dart:464
#5      _CodeFieldState._updatePopupOffset
code_field.dart:427
#6      ChangeNotifier.notifyListeners
change_notifier.dart:381
#7      CodeController.analyzeCode
code_controller.dart:188
<asynchronous suspension>
(elided 2 frames from class _AssertionError)
The CodeController sending notification was: CodeController#66ff9(TextEditingValue(text: ┤{}├, selection: TextSelection.invalid, composing: TextRange(start: -1, end: -1)))

This Is the related code, but, as I said, going back to 0.2.9 it works without problem even with Flutter 3.7.3 under Macos with a Macos desktop app:

 return  CodeTheme(
            data: CodeThemeData(),
            child: SingleChildScrollView(
              child: CodeField(
                controller: _codeController,
                minLines: 10,
              ),
            )),

Thanks. Stefano