Update QuillEditor constructor

pull/13/head
singerdmx 4 years ago
parent 31f16bedf0
commit 2b6086ae3f
  1. 35
      app/lib/pages/home_page.dart
  2. 7
      lib/widgets/editor.dart

@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_quill/models/documents/document.dart';
@ -10,7 +9,6 @@ import 'package:flutter_quill/widgets/controller.dart';
import 'package:flutter_quill/widgets/default_styles.dart';
import 'package:flutter_quill/widgets/editor.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
@ -34,12 +32,14 @@ class _HomePageState extends State<HomePage> {
final result = await rootBundle.loadString('assets/welcome.note');
final doc = Document.fromJson(jsonDecode(result));
setState(() {
_controller = QuillController(document: doc, selection: TextSelection.collapsed(offset: 0));
_controller = QuillController(
document: doc, selection: TextSelection.collapsed(offset: 0));
});
} catch (error) {
final doc = Document()..insert(0, 'Empty asset');
setState(() {
_controller = QuillController(document: doc, selection: TextSelection.collapsed(offset: 0));
_controller = QuillController(
document: doc, selection: TextSelection.collapsed(offset: 0));
});
}
}
@ -51,18 +51,17 @@ class _HomePageState extends State<HomePage> {
}
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.grey.shade800,
elevation: 0,
centerTitle: false,
title: Text(
'Flutter Quill',
),
actions: [
],
appBar: AppBar(
backgroundColor: Colors.grey.shade800,
elevation: 0,
centerTitle: false,
title: Text(
'Flutter Quill',
),
body: _buildWelcomeEditor(context),
);
actions: [],
),
body: _buildWelcomeEditor(context),
);
}
Widget _buildWelcomeEditor(BuildContext context) {
@ -83,6 +82,7 @@ class _HomePageState extends State<HomePage> {
embedBuilder: _embedBuilder,
enableInteractiveSelection: true,
expands: false,
padding: EdgeInsets.zero,
),
),
),
@ -101,8 +101,7 @@ class _HomePageState extends State<HomePage> {
}
throw UnimplementedError(
'Embeddable type "${node.value.type}" is not supported by default embed '
'builder of QuillEditor. You must pass your own builder function to '
'embedBuilder property of QuillEditor or QuillField widgets.');
'builder of QuillEditor. You must pass your own builder function to '
'embedBuilder property of QuillEditor or QuillField widgets.');
}
}

@ -98,7 +98,7 @@ class QuillEditor extends StatefulWidget {
this.focusNode,
@required this.scrollController,
@required this.scrollable,
this.padding,
@required this.padding,
@required this.autoFocus,
this.showCursor,
@required this.readOnly,
@ -106,8 +106,8 @@ class QuillEditor extends StatefulWidget {
this.minHeight,
this.maxHeight,
@required this.expands,
this.textCapitalization,
this.keyboardAppearance,
this.textCapitalization = TextCapitalization.sentences,
this.keyboardAppearance = Brightness.light,
this.scrollPhysics,
this.onLaunchUrl,
@required this.embedBuilder})
@ -437,6 +437,7 @@ class RawEditor extends StatefulWidget {
showCursor = showCursor ?? !readOnly,
assert(embedBuilder != null, 'embedBuilder cannot be null'),
assert(expands != null, 'expands cannot be null'),
assert(padding != null),
super(key: key);
@override

Loading…
Cancel
Save