singerdmx / flutter-quill

Rich text editor for Flutter

Home Page:https://pub.dev/packages/flutter_quill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

darkomenx opened this issue · comments

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)

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"}.

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