type '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>' for the base example documentation of package
darkomenx opened this issue · comments
darkomen commented
Is there an existing issue for this?
- I have searched the existing issues
Flutter Quill version
9.1.0
Steps to reproduce
flutter pub add flutter_quill
import package : import 'package:flutter_quill/flutter_quill.dart';
- create controller quill :
final QuillController _controller = QuillController.basic();
- create fake json representation data :
final json = jsonDecode(r'{"insert":"hello\n"}');
- 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)
kairan77 commented
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"}.
darkomen commented
Yeh I found this after. But when you start with your package it seems to confuse.
Thank you for your help and feedback 👍