Skip to content

Commit fd0860f

Browse files
committed
feat: null safety
1 parent 251505a commit fd0860f

File tree

11 files changed

+191
-180
lines changed

11 files changed

+191
-180
lines changed

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"proseWrap": "never"
3+
}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# highlight
1+
# highlight.dart
22

33
Syntax highlighting for Dart and Flutter, which supports lots of languages and themes.
44

55
[View gallery built with Flutter web](https://git-touch.github.io/highlight/)
66

7-
| Package | Version | Description |
8-
| -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
9-
| [highlight](https://github.com/pd4d10/highlight/tree/master/highlight) | [![pub](https://img.shields.io/pub/v/highlight)](https://pub.dev/packages/highlight) | Core syntax highlighting library written in Dart |
10-
| [flutter_highlight](https://github.com/pd4d10/highlight/tree/master/flutter_highlight) | [![pub](https://img.shields.io/pub/v/flutter_highlight)](https://pub.dev/packages/flutter_highlight) | Flutter syntax highlighting widget |
11-
| |
7+
| Package | Version | Description |
8+
| --- | --- | --- |
9+
| [highlight](https://github.com/pd4d10/highlight/tree/master/highlight) | [![pub](https://img.shields.io/pub/v/highlight)](https://pub.dev/packages/highlight) | Core syntax highlighting library written in Dart |
10+
| [flutter_highlight](https://github.com/pd4d10/highlight/tree/master/flutter_highlight) | [![pub](https://img.shields.io/pub/v/flutter_highlight)](https://pub.dev/packages/flutter_highlight) | Flutter syntax highlighting widget |
11+
| |
1212

1313
## References
1414

flutter_highlight/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ environment:
1919
dependencies:
2020
flutter:
2121
sdk: flutter
22-
url_launcher: ^5.4.1
22+
url_launcher: ^6.0.2
2323
flutter_highlight:
2424
path: ../
2525

flutter_highlight/lib/flutter_highlight.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ class HighlightView extends StatelessWidget {
1212
/// It is recommended to give it a value for performance
1313
///
1414
/// [All available languages](https://github.com/pd4d10/highlight/tree/master/highlight/lib/languages)
15-
final String language;
15+
final String? language;
1616

1717
/// Highlight theme
1818
///
1919
/// [All available themes](https://github.com/pd4d10/highlight/blob/master/flutter_highlight/lib/themes)
2020
final Map<String, TextStyle> theme;
2121

2222
/// Padding
23-
final EdgeInsetsGeometry padding;
23+
final EdgeInsetsGeometry? padding;
2424

2525
/// Text styles
2626
///
2727
/// Specify text styles such as font family and font size
28-
final TextStyle textStyle;
28+
final TextStyle? textStyle;
2929

3030
HighlightView(
3131
String input, {
@@ -45,16 +45,16 @@ class HighlightView extends StatelessWidget {
4545
if (node.value != null) {
4646
currentSpans.add(node.className == null
4747
? TextSpan(text: node.value)
48-
: TextSpan(text: node.value, style: theme[node.className]));
48+
: TextSpan(text: node.value, style: theme[node.className!]));
4949
} else if (node.children != null) {
5050
List<TextSpan> tmp = [];
51-
currentSpans.add(TextSpan(children: tmp, style: theme[node.className]));
51+
currentSpans.add(TextSpan(children: tmp, style: theme[node.className!]));
5252
stack.add(currentSpans);
5353
currentSpans = tmp;
5454

55-
node.children.forEach((n) {
55+
node.children!.forEach((n) {
5656
_traverse(n);
57-
if (n == node.children.last) {
57+
if (n == node.children!.last) {
5858
currentSpans = stack.isEmpty ? spans : stack.removeLast();
5959
}
6060
});
@@ -93,7 +93,7 @@ class HighlightView extends StatelessWidget {
9393
child: RichText(
9494
text: TextSpan(
9595
style: _textStyle,
96-
children: _convert(highlight.parse(source, language: language).nodes),
96+
children: _convert(highlight.parse(source, language: language).nodes!),
9797
),
9898
),
9999
);

flutter_highlight/pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
name: flutter_highlight
22
description: Syntax highlighting widget for Flutter with lots of languages and themes support.
33
version: 0.6.0+1
4-
author: Rongjian Zhang <pd4d10@gmail.com>
54
homepage: https://github.com/git-touch/highlight
65

76
environment:
8-
sdk: ">=2.3.0 <3.0.0"
7+
sdk: ">=2.12.0 <3.0.0"
98

109
dependencies:
1110
flutter:

0 commit comments

Comments
 (0)