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
197 stars 47 forks source link

CodeField error #275

Open juancai0104 opened 2 months ago

juancai0104 commented 2 months ago

When I run my project, using the CodeField option I get an error in the console, but the application continues working normally, should I be worried? am I doing something wrong?

I am using Flutter version 3.22.2, Dart version 3.4.3 and Android Studio version 2023.3.

This is mi code:

`import 'package:compilertest/common/snippets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_code_editor/flutter_code_editor.dart'; import 'package:flutter_highlight/themes/monokai-sublime.dart'; import 'package:highlight/languages/java.dart'; import 'package:highlight/languages/python.dart';

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

final controller = CodeController( text: javaFactorialSnippet, language: java, );

class CodeEditor extends StatelessWidget { const CodeEditor({super.key});

@override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( appBar: AppBar(), body: CodeTheme( data: CodeThemeData(styles: monokaiSublimeTheme), child: SingleChildScrollView( child: CodeField( controller: controller

        ),
      ),
    ),
  ),
);

} }`

This is the error:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'... √ Built build\app\outputs\flutter-apk\app-debug.apk Installing build\app\outputs\flutter-apk\app-debug.apk... Debug service listening on ws://127.0.0.1:53204/z8ph6xCROz0=/ws Syncing files to device sdk gphone64 x86 64... I/le.compilertest(14593): Compiler allocated 4968KB to compile void android.view.ViewRootImpl.performTraversals()

======== Exception caught by foundation library ==================================================== The following assertion was thrown while dispatching notifications for CodeController: RenderBox was not laid out: RenderTransform#73e3d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 2165 pos 12: 'hasSize'

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.yml

When the exception was thrown, this was the stack:

2 RenderBox.size (package:flutter/src/rendering/box.dart:2165:12)

3 RenderTransform._effectiveTransform (package:flutter/src/rendering/proxy_box.dart:2477:49)

4 RenderTransform.applyPaintTransform (package:flutter/src/rendering/proxy_box.dart:2560:24)

5 RenderObject.getTransformTo (package:flutter/src/rendering/object.dart:3354:24)

6 RenderBox.localToGlobal (package:flutter/src/rendering/box.dart:2886:39)

7 _CodeFieldState._onTextChanged (package:flutter_code_editor/src/code_field/code_field.dart:330:28)

8 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)

9 CodeController.analyzeCode (package:flutter_code_editor/src/code_field/code_controller.dart:224:5)

(elided 2 frames from class _AssertionError) The CodeController sending notification was: CodeController#2b84a(TextEditingValue(text: ┤class MyClass { /// Calculates the factorial of the number. /// The number must be >= 0. static int factorial(int n) { if (n == 0) { return 1; } return n * factorial(n - 1); } public static void main(String[] args) { int num = 5; System.out.println("Factorial of " + num + " is " + factorial(5)); } } ├, selection: TextSelection.invalid, composing: TextRange(start: -1, end: -1))) ==================================================================================================== ======== 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': Failed assertion: line 157 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.yml When the exception was thrown, this was the stack: #2 ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:157:12) #3 ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:165:24) #4 _CodeFieldState._getPopupLeftOffset (package:flutter_code_editor/src/code_field/code_field.dart:524:34) #5 _CodeFieldState._updatePopupOffset (package:flutter_code_editor/src/code_field/code_field.dart:487:24) #6 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24) #7 CodeController.analyzeCode (package:flutter_code_editor/src/code_field/code_controller.dart:224:5) (elided 2 frames from class _AssertionError) The CodeController sending notification was: CodeController#2b84a(TextEditingValue(text: ┤class MyClass { /// Calculates the factorial of the number. /// The number must be >= 0. static int factorial(int n) { if (n == 0) { return 1; } return n * factorial(n - 1); } public static void main(String[] args) { int num = 5; System.out.println("Factorial of " + num + " is " + factorial(5)); } } ├, selection: TextSelection.invalid, composing: TextRange(start: -1, end: -1))) ====================================================================================================