singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.52k stars 801 forks source link

[Web] Unexpected Null Value #2076

Open fnyfauzi opened 1 month ago

fnyfauzi commented 1 month ago

Is there an existing issue for this?

The question

Hi, i have the following issue when using it with go_router

go_router: ^14.2.1
flutter_quill: ^10.1.2
flutter_quill_extensions: ^10.1.2

Thanks for your help.

My go_router is very simple:

GoRoute(
  name: 'art_page',
  path: 'art_page',
  pageBuilder: (context, state) {
    Map<String, dynamic> extra = state.extra as Map<String, dynamic>;
    Document document = extra['document'];
    return MaterialPage(
      key: state.pageKey,
      child: ArtPage(document: document),
    );
  },
),

// with Ontap:
onTap: () => context.pushNamed("art_page", extra: {'document': Document()}),

While the following is simple flutter quill:

class ArtPage extends StatefulWidget {
  const ArtPage({super.key, required this.document});
  final Document document;

  @override
  State<ArtPage> createState() => _ArtPageState();
}

class _ArtPageState extends State<ArtPage> {
  // final _controller = QuillController(document: Document()..insert(0, 'Halo'),selection: const TextSelection.collapsed(offset: 0));
  final _controller = QuillController.basic();
  final _editorFocusNode = FocusNode();
  final _editorScrollController = ScrollController();

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

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

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      backgroundColor: Colors.blueGrey,
      body: Column(
        children: [
          Builder(
            builder: (context) => QuillEditor(
              configurations: QuillEditorConfigurations(
                controller: _controller,
                builder: (context, rawEditor) => rawEditor,
              ),
              focusNode: _editorFocusNode,
              scrollController: _editorScrollController,
            ),
          ),          
        ],
      ),
    );
  }
}
[GoRouter] An extra with complex data type IdentityMap<String, Article> is provided without a codec. Consider provide a codec to GoRouter to prevent extra being dropped during serialization.
[GoRouter] popping /art_page
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following TypeErrorImpl was thrown building QuillEditorBuilderWidget:
Unexpected null value.

The relevant error-causing widget was:
  QuillEditor QuillEditor:file:///...

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 586:18  nullCheck
packages/flutter_quill/src/editor/widgets/default_styles.dart 437:43              getInstance
packages/flutter_quill/src/editor/raw_editor/raw_editor_state.dart 1249:41        didChangeDependencies
packages/flutter/src/widgets/framework.dart 5636:5                                [_firstBuild]
packages/flutter/src/widgets/framework.dart 5463:5                                mount