@ -9,9 +9,9 @@ import 'package:flutter/foundation.dart';
import ' package:flutter/material.dart ' ;
import ' package:flutter/services.dart ' ;
import ' package:flutter_quill/extensions.dart ' ;
import ' package:flutter_quill/flutter_quill.dart ' hide Text ;
import ' package:flutter_quill/flutter_quill.dart ' hide Quill Text;
import ' package:flutter_quill_extensions/flutter_quill_extensions.dart ' ;
import ' package:path/path.dart ' ;
import ' package:path/path.dart ' as path ;
import ' package:path_provider/path_provider.dart ' ;
import ' ../universal_ui/universal_ui.dart ' ;
@ -61,7 +61,9 @@ class _HomePageState extends State<HomePage> {
final doc = Document ( ) . . insert ( 0 , ' Empty asset ' ) ;
setState ( ( ) {
_controller = QuillController (
document: doc , selection: const TextSelection . collapsed ( offset: 0 ) ) ;
document: doc ,
selection: const TextSelection . collapsed ( offset: 0 ) ,
) ;
} ) ;
}
}
@ -174,19 +176,17 @@ class _HomePageState extends State<HomePage> {
} ) ;
}
Widget _buildWelcomeEditor ( BuildContext context ) {
Widget quillEditor = QuillEditor (
controller: _controller ! ,
QuillEditor get quillEditor {
if ( kIsWeb ) {
return QuillEditor (
scrollController: ScrollController ( ) ,
scrollable: true ,
focusNode: _focusNode ,
autoFocus: false ,
readOnly: false ,
placeholder: ' Add content ' ,
enableSelectionToolbar: isMobile ( ) ,
expands: false ,
padding: EdgeInsets . zero ,
onImagePaste: _onImagePaste ,
onTapUp: ( details , p1 ) {
return _onTripleClickSelection ( ) ;
} ,
@ -202,31 +202,24 @@ class _HomePageState extends State<HomePage> {
VerticalSpacing ( 0 , 0 ) ,
null ) ,
sizeSmall: TextStyle ( fontSize: 9 ) ,
subscript: TextStyle (
fontFamily: ' SF-UI-Display ' ,
fontFeatures: [ FontFeature . subscripts ( ) ] ,
) ,
superscript: TextStyle (
fontFamily: ' SF-UI-Display ' ,
fontFeatures: [ FontFeature . superscripts ( ) ] ,
) ,
) ,
embedBuilders: [
. . . FlutterQuillEmbeds . builders ( ) ,
. . . defaultEmbedBuildersWeb ,
TimeStampEmbedBuilderWidget ( )
] ,
) ;
if ( kIsWeb ) {
quillEditor = QuillEditor (
controller: _controller ! ,
}
return QuillEditor (
scrollController: ScrollController ( ) ,
scrollable: true ,
focusNode: _focusNode ,
autoFocus: false ,
readOnly: false ,
placeholder: ' Add content ' ,
enableSelectionToolbar: isMobile ( ) ,
expands: false ,
padding: EdgeInsets . zero ,
onImagePaste: _onImagePaste ,
onTapUp: ( details , p1 ) {
return _onTripleClickSelection ( ) ;
} ,
@ -242,51 +235,85 @@ class _HomePageState extends State<HomePage> {
VerticalSpacing ( 0 , 0 ) ,
null ) ,
sizeSmall: TextStyle ( fontSize: 9 ) ,
subscript: TextStyle (
fontFamily: ' SF-UI-Display ' ,
fontFeatures: [ FontFeature . subscripts ( ) ] ,
) ,
superscript: TextStyle (
fontFamily: ' SF-UI-Display ' ,
fontFeatures: [ FontFeature . superscripts ( ) ] ,
) ,
) ,
embedBuilders: [
. . . defaultEmbedBuildersWeb ,
. . . FlutterQuillEmbeds . builders ( ) ,
TimeStampEmbedBuilderWidget ( )
] ) ;
] ,
) ;
}
var toolbar = QuillToolbar . basic (
context: context ,
QuillToolbar get quillToolbar {
if ( kIsWeb ) {
return QuillToolbar . basic (
embedButtons: FlutterQuillEmbeds . buttons (
/ / provide a callback to enable picking images from device .
/ / if omit , " image " button only allows adding images from url .
/ / same goes for videos .
onImagePickCallback: _onImagePickCallback ,
onVideoPickCallback: _onVideoPickCallback ,
/ / uncomment to provide a custom " pick from " dialog .
/ / mediaPickSettingSelector: _selectMediaPickSetting ,
/ / uncomment to provide a custom " pick from " dialog .
/ / cameraPickSettingSelector: _selectCameraPickSetting ,
webImagePickImpl: _webImagePickImpl ,
) ,
showAlignmentButtons: true ,
afterButtonPressed: _focusNode . requestFocus ,
) ;
if ( kIsWeb ) {
toolbar = QuillToolbar . basic (
context: context ,
}
if ( _isDesktop ( ) ) {
return QuillToolbar . basic (
embedButtons: FlutterQuillEmbeds . buttons (
onImagePickCallback: _onImagePickCallback ,
webImagePickImpl: _webImagePickImpl ,
filePickImpl: openFileSystemPickerForDesktop ,
) ,
showAlignmentButtons: true ,
afterButtonPressed: _focusNode . requestFocus ,
) ;
}
if ( _isDesktop ( ) ) {
toolbar = QuillToolbar . basic (
context: context ,
return QuillToolbar . basic (
embedButtons: FlutterQuillEmbeds . buttons (
/ / provide a callback to enable picking images from device .
/ / if omit , " image " button only allows adding images from url .
/ / same goes for videos .
onImagePickCallback: _onImagePickCallback ,
filePickImpl: openFileSystemPickerForDesktop ,
onVideoPickCallback: _onVideoPickCallback ,
/ / uncomment to provide a custom " pick from " dialog .
/ / mediaPickSettingSelector: _selectMediaPickSetting ,
/ / uncomment to provide a custom " pick from " dialog .
/ / cameraPickSettingSelector: _selectCameraPickSetting ,
) ,
showAlignmentButtons: true ,
afterButtonPressed: _focusNode . requestFocus ,
) ;
}
Widget _buildWelcomeEditor ( BuildContext context ) {
/ / BUG in web ! ! should not releated to this pull request
/ / /
/ / / ═ ═ ╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
/ / / ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
/ / The following bool object was thrown building MediaQuery
/ / ( MediaQueryData ( size: Size ( 769.0 , 1205.0 ) ,
/ / devicePixelRatio: 1.0 , textScaleFactor: 1.0 , platformBrightness:
/ / Brightness . dark , padding:
/ / EdgeInsets . zero , viewPadding: EdgeInsets . zero , viewInsets:
/ / EdgeInsets . zero ,
/ / systemGestureInsets:
/ / EdgeInsets . zero , alwaysUse24HourFormat: false , accessibleNavigation:
/ / false ,
/ / highContrast: false ,
/ / disableAnimations: false , invertColors: false , boldText: false ,
/ / navigationMode: traditional ,
/ / gestureSettings: DeviceGestureSettings ( touchSlop: null ) , displayFeatures:
/ / [ ]
/ / ) ) :
/ / false
/ / The relevant error - causing widget was:
/ / SafeArea
/ / /
/ / /
return SafeArea (
child: QuillProvider (
configurations: QuillConfigurations (
@ -312,9 +339,9 @@ class _HomePageState extends State<HomePage> {
child: Container (
padding:
const EdgeInsets . symmetric ( vertical: 16 , horizontal: 8 ) ,
child: t oolbar,
child: quillT oolbar,
) )
: Container ( child: t oolbar)
: Container ( child: quillT oolbar)
] ,
) ,
) ,
@ -339,7 +366,7 @@ class _HomePageState extends State<HomePage> {
/ / Copies the picked file from temporary cache to applications directory
final appDocDir = await getApplicationDocumentsDirectory ( ) ;
final copiedFile =
await file . copy ( ' ${ appDocDir . path } / ${ basename ( file . path ) } ' ) ;
await file . copy ( ' ${ appDocDir . path } / ${ path . basename ( file . path ) } ' ) ;
return copiedFile . path . toString ( ) ;
}
@ -364,7 +391,7 @@ class _HomePageState extends State<HomePage> {
/ / Copies the picked file from temporary cache to applications directory
final appDocDir = await getApplicationDocumentsDirectory ( ) ;
final copiedFile =
await file . copy ( ' ${ appDocDir . path } / ${ basename ( file . path ) } ' ) ;
await file . copy ( ' ${ appDocDir . path } / ${ path . basename ( file . path ) } ' ) ;
return copiedFile . path . toString ( ) ;
}
@ -462,8 +489,8 @@ class _HomePageState extends State<HomePage> {
/ / Saves the image to applications directory
final appDocDir = await getApplicationDocumentsDirectory ( ) ;
final file = await File (
' ${ appDocDir . path } / ${ basename ( ' $ {DateTime.now().millisecondsSinceEpoch } .png ' ) } ' )
. writeAsBytes ( imageBytes , flush: true ) ;
' ${ appDocDir . path } / ${ path . basename ( ' $ {DateTime.now().millisecondsSinceEpoch } .png ' ) } ' ,
) . writeAsBytes ( imageBytes , flush: true ) ;
return file . path . toString ( ) ;
}