Skip to content

Commit cda282f

Browse files
committed
chore: Adding homepage section. #1
1 parent a2213d4 commit cda282f

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

README.md

+83-1
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,87 @@ In `lib`, create a file called `home_page.dart`
263263
and paste the following code.
264264

265265
```dart
266+
/// Importing all the needed imports so the README is easier to follow
267+
import 'dart:async';
268+
import 'dart:io';
269+
import 'dart:ui';
270+
271+
import 'package:app/main.dart';
272+
import 'package:file_picker/file_picker.dart';
273+
import 'package:flutter/material.dart';
274+
import 'package:flutter_quill/extensions.dart';
275+
import 'package:flutter_quill/flutter_quill.dart' hide Text;
276+
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
277+
import 'package:path/path.dart';
278+
import 'package:path_provider/path_provider.dart';
279+
280+
281+
/// Home page with the `flutter-quill` editor
282+
class HomePage extends StatefulWidget {
283+
const HomePage({
284+
required this.platformService, super.key,
285+
});
286+
287+
final PlatformService platformService;
288+
289+
@override
290+
HomePageState createState() => HomePageState();
291+
}
292+
293+
class HomePageState extends State<HomePage> {
294+
295+
/// `flutter-quill` editor controller
296+
QuillController? _controller;
297+
298+
@override
299+
void initState() {
300+
super.initState();
301+
}
302+
303+
@override
304+
Widget build(BuildContext context) {
305+
/// Loading widget if controller's not loaded
306+
if (_controller == null) {
307+
return const Scaffold(body: Center(child: Text('Loading...')));
308+
}
309+
310+
/// Returning scaffold with editor as body
311+
return Scaffold(
312+
appBar: AppBar(
313+
backgroundColor: Colors.white,
314+
elevation: 0,
315+
centerTitle: false,
316+
title: const Text(
317+
'Flutter Quill',
318+
),
319+
),
320+
body: Container(),
321+
);
322+
}
323+
}
324+
```
325+
326+
We are importing all the needed imports
327+
right off the bat so we don't have to deal with those later 😉.
328+
329+
In this file,
330+
we are simply creating a basic **stateful widget** `HomePage`
331+
that renders a `Scaffold` widget
332+
with a `Container()` as its body.
333+
334+
You might have noticed we've defined a
335+
[**`QuillController`**](https://github.com/singerdmx/flutter-quill/blob/36d72c1987f0cb8d6c689c12542600364c07e20f/lib/src/widgets/controller.dart)
336+
`_controller`.
337+
This controller will keep track of the
338+
**`deltas`**
339+
and the **text** that is written in the editor.
340+
341+
> [!NOTE]
342+
> `Deltas` is an object format that represents
343+
> contents and changes in a readable way.
344+
> To learn about them, we *highly suggest* visiting
345+
> https://quilljs.com/docs/delta.
346+
347+
For the Quill Editor to properly function,
348+
we are going to use this `_controller` parameter later on.
266349

267-
```

0 commit comments

Comments
 (0)