appflowy-editor/example/lib/pages/ten_thousand_links_showcase.dart
Lucas 41335c54ae
chore: merge flutter 3_27_4 into main branch (#1228)
* chore: merge flutter/3_27_4 to main branch

* chore: code format

* fix: unit tests
2026-07-27 15:37:27 +08:00

50 lines
1.3 KiB
Dart

import 'dart:convert';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:example/pages/editor.dart';
import 'package:flutter/material.dart';
class TenThousandLinksShowcase extends StatefulWidget {
const TenThousandLinksShowcase({super.key});
@override
State<TenThousandLinksShowcase> createState() =>
_TenThousandLinksShowcaseState();
}
class _TenThousandLinksShowcaseState extends State<TenThousandLinksShowcase> {
late final Future<String> _jsonString = _buildLinksDocument();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('10,000 Links Showcase')),
body: Editor(
jsonString: _jsonString,
onEditorStateChange: (_) {},
),
);
}
Future<String> _buildLinksDocument() {
final document = Document(
root: pageNode(
children: List.generate(
10000,
(index) => paragraphNode(
delta: Delta()
..insert(
'Link ${index + 1}',
attributes: {
AppFlowyRichTextKeys.href:
'https://example.com/links/${index + 1}',
},
),
),
),
),
);
return Future.value(jsonEncode(document.toJson()));
}
}