Last updated:
0 purchases
nitori message
A message builder for Nitori, provides several useful functions to construct or parse message elements of Satori Protocol.
Usage #
Construct a message #
import 'package:nitori_message/nitori_message.dart' as n;
var message = n.Message(
children: [
n.At(id: '001', name: 'Kawashiro Nitori'),
n.Text('Hello, world!'),
n.Image(src: 'https://example.com/image.png'),
n.LineBreak(),
n.Bold('Welcome to Nitori: '),
n.Sharp(id: '001', name: 'Kawashiro Channel'),
],
); // n.Message
copied to clipboard
The code above will produce:
<message>
<at id="001" name="Kawashiro Nitori" />
Hello, world!
<img src="https://example.com/image.png" />
<br />
<b>Welcome to Nitori: </b>
<sharp id="001" name="Kawashiro Channel" />
</message>
copied to clipboard
You will notice there are some differences between the class names and the produced tags, this is because the class names are designed to be more readable and easy to use, while the tags are should be the same as those in Satori Protocol.
You could see the Elements Cheat Sheet for more details.
Parse a message #
import 'package:nitori_message/nitori_message.dart' as n;
var message = n.Message.parse(
'<message>'
'<at id="001" name="Kawashiro Nitori" />'
'Hello, world!'
'<img src="https://example.com/image.png" />'
'<br />'
'<b>Welcome to Nitori: </b>'
'<sharp id="001" name="Kawashiro Channel" />'
'</message>',
); // n.Message
copied to clipboard
The code above will produce a structure like this:
n.Message(
children: [
n.At(id: '001', name: 'Kawashiro Nitori'),
n.Text('Hello, world!'),
n.Image(src: 'https://example.com/image.png'),
n.LineBreak(),
n.Bold('Welcome to Nitori: '),
n.Sharp(id: '001', name: 'Kawashiro Channel'),
],
); // n.Message
copied to clipboard
Since Nitori overrides the toString() method of each element, you could use print(message) to see the result.
print(message);
// =>
// <message>
// <at id="001" name="Kawashiro Nitori" />
// Hello, world!
// <img src="https://example.com/image.png" />
// <br />
// <b>Welcome to Nitori: </b>
// <sharp id="001" name="Kawashiro Channel" />
// </message>
copied to clipboard
Elements Cheat Sheet #
Class Name
Satori Element Name
Note
Text
plain text
Represent a text node.
At
<at>
Sharp
<sharp>
Anchor
<a>
Image
<img>
Audio
<audio>
Video
<video>
File
<file>
Bold
<b>
Idiomatic
<i>
Underline
<u>
Strikethrough
<s>
Spoler
<spl>
Code
<code>
Superscript
<sup>
Subscript
<sub>
LineBreak
<br>
Paragraph
<p>
Message
<message>
Quote
<quote>
Author
<author>
Button
<button>
Not implemented yet
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.