Feat: added Spell checker to example

pull/2127/head
CatHood0 8 months ago
parent d90afdca03
commit 590b86bb15
  1. 16
      example/lib/screens/home/widgets/home_screen.dart
  2. 24
      example/lib/screens/quill/quill_screen.dart

@ -15,11 +15,22 @@ import '../../quill/samples/quill_videos_sample.dart';
import '../../settings/widgets/settings_screen.dart';
import 'example_item.dart';
class HomeScreen extends StatelessWidget {
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
static const routeName = '/home';
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
void dispose() {
SpellCheckerServiceProvider.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -67,8 +78,7 @@ class HomeScreen extends StatelessWidget {
Icons.home,
size: 50,
),
text:
'If you want to see how the editor work with default content, '
text: 'If you want to see how the editor work with default content, '
'see any samples or you are working on it',
onPressed: () => Navigator.of(context).pushNamed(
QuillScreen.routeName,

@ -3,7 +3,7 @@ import 'dart:convert' show jsonEncode;
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'
show FlutterQuillEmbeds, QuillSharedExtensionsConfigurations;
show FlutterQuillEmbeds, FlutterQuillExtensions, QuillSharedExtensionsConfigurations;
import 'package:share_plus/share_plus.dart' show Share;
import '../../extensions/scaffold_messenger.dart';
@ -11,6 +11,8 @@ import '../shared/widgets/home_screen_button.dart';
import 'my_quill_editor.dart';
import 'my_quill_toolbar.dart';
var _isActivatedSpellChecker = false;
@immutable
class QuillScreenArgs {
const QuillScreenArgs({required this.document});
@ -60,6 +62,23 @@ class _QuillScreenState extends State<QuillScreen> {
appBar: AppBar(
title: const Text('Flutter Quill'),
actions: [
IconButton(
tooltip: 'Spell-checker',
onPressed: () {
if (!_isActivatedSpellChecker) {
FlutterQuillExtensions.useSpellCheckerService(Localizations.localeOf(context).languageCode);
} else {
SpellCheckerServiceProvider.dispose(onlyPartial: true);
SpellCheckerServiceProvider.turnOffService();
}
_isActivatedSpellChecker = !_isActivatedSpellChecker;
setState(() {});
},
icon: Icon(
Icons.document_scanner,
color: _isActivatedSpellChecker ? Colors.red : null,
),
),
IconButton(
tooltip: 'Share',
onPressed: () {
@ -128,8 +147,7 @@ class _QuillScreenState extends State<QuillScreen> {
return const QuillSharedConfigurations(
// locale: Locale('en'),
extraConfigurations: {
QuillSharedExtensionsConfigurations.key:
QuillSharedExtensionsConfigurations(
QuillSharedExtensionsConfigurations.key: QuillSharedExtensionsConfigurations(
assetsPrefix: 'assets', // Defaults to assets
),
},

Loading…
Cancel
Save