Skip to content

Commit 2ffd54a

Browse files
committed
Add lint and improve code
1 parent 0caa85c commit 2ffd54a

File tree

9 files changed

+600
-579
lines changed

9 files changed

+600
-579
lines changed

analysis_options.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include: package:lint/analysis_options.yaml
2+
3+
analyzer:
4+
strong-mode:
5+
implicit-casts: false
6+
implicit-dynamic: false
7+
errors:
8+
todo: info
9+
linter:
10+
rules:
11+
always_put_required_named_parameters_first: true
12+
sort_constructors_first: true
13+
prefer_single_quotes: true
14+
always_specify_types: true
15+
lines_longer_than_80_chars: true
16+
# public_member_api_docs: true

example/lib/main.dart

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import 'package:simple_html_css/simple_html_css.dart';
22
import 'package:flutter/material.dart';
33

4-
void main() {
5-
runApp(Home());
6-
}
4+
void main() => runApp(Home());
75

86
class Home extends StatelessWidget {
97
@override
108
Widget build(BuildContext context) {
11-
String htmlContent = """
9+
const String htmlContent = """
1210
<body>
1311
1412
<h1 style='color: white; font-size:50px; font-style:italic; background-color: rgb(0,122,255); font-weight:100;)'> Hello word! </h1>
@@ -24,17 +22,17 @@ class Home extends StatelessWidget {
2422
""";
2523

2624
// or use HTML.toRichText()
27-
var textSpan = HTML.toTextSpan(
25+
final TextSpan textSpan = HTML.toTextSpan(
2826
context,
2927
htmlContent,
30-
linksCallback: (link) {
31-
print("You clicked on $link");
28+
linksCallback: (dynamic link) {
29+
debugPrint('You clicked on ${link.toString()}');
3230
},
3331
// as name suggests, optionally set the default text style
3432
defaultTextStyle: TextStyle(color: Colors.grey[700]),
35-
overrideStyle: {
36-
"p": TextStyle(fontSize: 17.3),
37-
"a": TextStyle(wordSpacing: 2),
33+
overrideStyle: <String, TextStyle>{
34+
'p': const TextStyle(fontSize: 17.3),
35+
'a': const TextStyle(wordSpacing: 2),
3836
// specify any tag not just the supported ones,
3937
// and apply TextStyles to them and/override them
4038
},
@@ -43,7 +41,7 @@ class Home extends StatelessWidget {
4341
return MaterialApp(
4442
debugShowCheckedModeBanner: false,
4543
home: Scaffold(
46-
appBar: AppBar(title: Text("Demo")),
44+
appBar: AppBar(title: Text('Demo')),
4745
body: Container(
4846
color: Colors.white,
4947
padding: EdgeInsets.all(16.0),

lib/simple_html_css.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
library simple_html_css;
22

3+
export 'src/html_stylist.dart';
34
/*
45
* Modified work: Copyright 2020 Ali Ahamed Thowfeek
56
* Original work: Copyright 2019 Ashraff Hathibelagal
@@ -19,4 +20,3 @@ library simple_html_css;
1920

2021
export 'src/internals.dart';
2122
export 'src/utils.dart';
22-
export 'src/html_stylist.dart';

0 commit comments

Comments
 (0)