flutter_quill_syncme 10.8.5 flutter_quill_syncme: ^10.8.5 copied to clipboard
A rich text editor built for Android, iOS, Web, and desktop platforms. It's the WYSIWYG editor and a Quill component for Flutter.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart'
show
GlobalCupertinoLocalizations,
GlobalMaterialLocalizations,
GlobalWidgetsLocalizations;
import 'package:flutter_quill/flutter_quill.dart' show Document;
import 'package:flutter_quill/translations.dart' show FlutterQuillLocalizations;
import 'screens/home/widgets/home_screen.dart';
import 'screens/quill/quill_screen.dart';
import 'screens/quill/samples/quill_default_sample.dart';
import 'screens/quill/samples/quill_images_sample.dart';
import 'screens/quill/samples/quill_text_sample.dart';
import 'screens/quill/samples/quill_videos_sample.dart';
import 'screens/settings/cubit/settings_cubit.dart';
import 'screens/settings/widgets/settings_screen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => SettingsCubit(),
),
],
child: BlocBuilder<SettingsCubit, SettingsState>(
builder: (context, state) {
return MaterialApp(
title: 'Flutter Quill Demo',
theme: ThemeData(
useMaterial3: true,
visualDensity: VisualDensity.adaptivePlatformDensity,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.light,
seedColor: Colors.red,
),
),
darkTheme: ThemeData(
useMaterial3: true,
visualDensity: VisualDensity.adaptivePlatformDensity,
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: Colors.red,
),
),
themeMode: state.themeMode,
debugShowCheckedModeBanner: false,
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
// Uncomment this line to use provide flutter quill localizations
// in your widgets app, otherwise the quill widgets will provide it
// internally:
// FlutterQuillLocalizations.delegate,
],
supportedLocales: FlutterQuillLocalizations.supportedLocales,
routes: {
SettingsScreen.routeName: (context) => const SettingsScreen(),
},
onGenerateRoute: (settings) {
final name = settings.name;
if (name == HomeScreen.routeName) {
return MaterialPageRoute(
builder: (context) {
return const HomeScreen();
},
);
}
if (name == QuillScreen.routeName) {
return MaterialPageRoute(
builder: (context) {
final args = settings.arguments as QuillScreenArgs;
return QuillScreen(
args: args,
);
},
);
}
return null;
},
onUnknownRoute: (settings) {
return MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
title: const Text('Not found'),
),
body: const Text('404'),
),
);
},
home: Builder(
builder: (context) {
final screen = switch (state.defaultScreen) {
DefaultScreen.home => const HomeScreen(),
DefaultScreen.settings => const SettingsScreen(),
DefaultScreen.imagesSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillImagesSample),
),
),
DefaultScreen.videosSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillVideosSample),
),
),
DefaultScreen.textSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillTextSample),
),
),
DefaultScreen.emptySample => QuillScreen(
args: QuillScreenArgs(
document: Document(),
),
),
DefaultScreen.defaultSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillDefaultSample),
),
),
};
return AnimatedSwitcher(
duration: const Duration(milliseconds: 330),
transitionBuilder: (child, animation) {
// This animation is from flutter.dev example
const begin = Offset(0, 1);
const end = Offset.zero;
const curve = Curves.ease;
final tween = Tween(
begin: begin,
end: end,
).chain(
CurveTween(curve: curve),
);
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
child: screen,
);
},
),
);
},
),
);
}
}