๐Ÿ“ฆ amake / org_flutter

๐Ÿ“„ README.md ยท 79 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79# org_flutter

[Org Mode](https://orgmode.org/) widgets for Flutter.

# Usage

For parsing Org Mode documents, see
[org_parser](https://github.com/amake/org_parser). For an example application
that displays Org Mode documents with org_parser and org_flutter, see
[Orgro](https://orgro.org).

The simplest way to display an Org Mode document in your Flutter application is
to use the `Org` widget:

```dart
import 'package:org_flutter/org_flutter.dart';

class MyOrgViewWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return Org('''* TODO [#A] foo bar
baz buzz''');
  }
}
```

See the [example](./example/lib/main.dart) for more.

## Rich text

Use Org markup to create rich `Text`-equivalent widgets with `OrgText`.

```dart
OrgText('*This* is a /rich/ text label ([[https://example.com][details]])')
```

## Advanced

For more advanced usage, such as specifying link handling, use `OrgController`
in concert with `OrgRootWidget`:

```dart
import 'package:org_flutter/org_flutter.dart';

Widget build(BuildContext context) {
  final doc = OrgDocument.parse(
    rawOrgModeDocString,
    // Interpret e.g. #+TODO: settings at the cost of a second parsing pass
    interpretEmbeddedSettings: true,
  );
  return OrgController(
    root: doc,
    child: OrgLocator( // Include OrgLocator to enable tap-to-jump on footnotes, etc.
      child: OrgRootWidget(
        style: myTextStyle,
        onLinkTap: launch, // e.g. from url_launcher package
        child: OrgDocumentWidget(doc),
      ),
    ),
  );
}
```

Place `OrgController` higher up in your widget hierarchy and access via
`OrgController.of(context)` to dynamically control various properties of the
displayed document:

```dart
IconButton(
  icon: const Icon(Icons.repeat),
  onPressed: OrgController.of(context).cycleVisibility,
);
```

## Text selection

The Org Mode text is not selectable by default, but you can make it so by
wrapping the widget in
[`SelectionArea`](https://api.flutter.dev/flutter/material/SelectionArea-class.html).