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

type '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>' for the base example documentation of package #1840

Open
1 task done
darkomenx opened this issue Apr 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@darkomenx
Copy link

Is there an existing issue for this?

Flutter Quill version

9.1.0

Steps to reproduce

  1. flutter pub add flutter_quill
  2. import package : import 'package:flutter_quill/flutter_quill.dart';
  3. create controller quill : final QuillController _controller = QuillController.basic();
  4. create fake json representation data : final json = jsonDecode(r'{"insert":"hello\n"}');
  5. add this json to document quill controller : _controller.document = Document.fromJson(json);

Expected results

Basic Quill editor widget with basic json representation example

Actual results

dart red error displayed

Code sample

Code sample
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';

final QuillController _controller = QuillController.basic();
final json = jsonDecode(r'{"insert":"hello\n"}');
_controller.document = Document.fromJson(json);

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
======== Exception caught by widgets library =======================================================
The following _TypeError was thrown building NoteView(dirty, dependencies: [_InheritedProviderScope<NoteModel?>], state: NoteViewState#8024f):
type '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>'

The relevant error-causing widget was: 
  NoteView NoteView:file:///C:/XXXXX/XXXXXXX/project/lib/presentation/screen/notes_screen.dart:97:47
When the exception was thrown, this was the stack: 
#0      NoteViewState.build (package:project/presentation/widget/note_view.dart:28:50)
@darkomenx darkomenx added the bug Something isn't working label Apr 29, 2024
@kairan77
Copy link

kairan77 commented May 5, 2024

This is not a bug, the controller takes a LIST of values.

Your input should be something like [{"insert":"hello\n"}] rather than {"insert":"hello\n"}.

@darkomenx
Copy link
Author

Yeh I found this after. But when you start with your package it seems to confuse.
Thank you for your help and feedback 👍

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

2 participants