Skip to content

Commit e0d6d99

Browse files
committed
Fix lint warnings
1 parent a5d558f commit e0d6d99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+350
-213
lines changed

demo_app/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:lint/analysis_options_package.yaml
1+
include: package:lint/analysis_options.yaml
22

33
analyzer:
44
exclude:

demo_app/lib/main.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import 'package:demo_app/screens/home.dart';
2+
import 'package:demo_app/widgets/popup_menu.dart';
13
import 'package:flutter/material.dart';
24

3-
import 'screens/home.dart';
4-
import 'widgets/popup_menu.dart';
5-
65
void main() => runApp(const MyApp());
76

87
class MyApp extends StatelessWidget {

demo_app/lib/screens/font_size.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class _Panel extends StatelessWidget {
4949
),
5050
const Divider(),
5151
HtmlWidget(
52-
'<p style="font-size: 1em">Almost every developer\'s favorite molecule is '
53-
'C<sub>8</sub>H<sub>10</sub>N<sub>4</sub>O<sub>2</sub>, '
52+
'<p style="font-size: 1em">Almost every developer\'s favorite '
53+
'molecule is C<sub>8</sub>H<sub>10</sub>N<sub>4</sub>O<sub>2</sub>, '
5454
'also known as "caffeine."</p>',
5555
),
5656
],

demo_app/lib/screens/golden.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class GoldensScreen extends StatefulWidget {
8888
const GoldensScreen({Key key}) : super(key: key);
8989

9090
@override
91-
_GoldensState createState() => _GoldensState();
91+
State<GoldensScreen> createState() => _GoldensState();
9292
}
9393

9494
class _GoldensState extends State<GoldensScreen> {

demo_app/lib/screens/hello_world_core.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import 'package:demo_app/screens/hello_world.dart' as enhanced;
12
import 'package:demo_app/widgets/popup_menu.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
45

5-
import 'hello_world.dart' as enhanced;
6-
76
class HelloWorldCoreScreen extends StatelessWidget {
87
const HelloWorldCoreScreen({Key key}) : super(key: key);
98

demo_app/lib/screens/home.dart

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1+
import 'package:demo_app/screens/audio.dart';
2+
import 'package:demo_app/screens/custom_styles_builder.dart';
3+
import 'package:demo_app/screens/custom_widget_builder.dart';
4+
import 'package:demo_app/screens/font_size.dart';
5+
import 'package:demo_app/screens/golden.dart';
6+
import 'package:demo_app/screens/hello_world.dart';
7+
import 'package:demo_app/screens/hello_world_core.dart';
8+
import 'package:demo_app/screens/huge_html.dart';
9+
import 'package:demo_app/screens/iframe.dart';
10+
import 'package:demo_app/screens/img.dart';
11+
import 'package:demo_app/screens/img_file.dart';
12+
import 'package:demo_app/screens/photo_view.dart';
13+
import 'package:demo_app/screens/smilie.dart';
14+
import 'package:demo_app/screens/video.dart';
15+
import 'package:demo_app/screens/wordpress.dart';
116
import 'package:demo_app/widgets/popup_menu.dart';
217
import 'package:flutter/material.dart';
318

4-
import 'audio.dart';
5-
import 'custom_styles_builder.dart';
6-
import 'custom_widget_builder.dart';
7-
import 'font_size.dart';
8-
import 'golden.dart';
9-
import 'hello_world.dart';
10-
import 'hello_world_core.dart';
11-
import 'huge_html.dart';
12-
import 'iframe.dart';
13-
import 'img.dart';
14-
import 'img_file.dart';
15-
import 'photo_view.dart';
16-
import 'smilie.dart';
17-
import 'video.dart';
18-
import 'wordpress.dart';
19-
2019
class HomeScreen extends StatelessWidget {
2120
static final _screens = <String, Widget Function()>{
2221
'Hello World': () => const HelloWorldScreen(),

demo_app/lib/screens/img_file.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class _ImgFileState extends State<_ImgFileTab> {
7373
Padding(
7474
padding: const EdgeInsets.all(8.0),
7575
child: Text(
76-
'This test will write a ${widget.fileExtension} file into '
77-
"the device's file system then try to render with an IMG tag. "
76+
'This test will write a ${widget.fileExtension} into '
77+
'the file system then try to render with an IMG tag. '
7878
'The actual file path is semi-random and it should be '
79-
'unique across tests (switch tab to test again and again).',
79+
'unique across tests (switch tab to re-test).',
8080
),
8181
),
8282
Center(

demo_app/lib/screens/photo_view.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import 'package:demo_app/screens/custom_widget_builder.dart'
2+
as custom_widget_builder;
13
import 'package:flutter/material.dart';
24
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
35
import 'package:photo_view/photo_view.dart';
46

5-
import 'custom_widget_builder.dart' as custom_widget_builder;
6-
77
class PhotoViewScreen extends StatelessWidget {
88
const PhotoViewScreen({Key key}) : super(key: key);
99

demo_app/pubspec.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ packages:
223223
path: "../packages/enhanced"
224224
relative: true
225225
source: path
226-
version: "0.8.3"
226+
version: "0.8.3+1"
227227
flutter_widget_from_html_core:
228228
dependency: "direct main"
229229
description:
230230
path: "../packages/core"
231231
relative: true
232232
source: path
233-
version: "0.8.3"
233+
version: "0.8.3+1"
234234
frontend_server_client:
235235
dependency: transitive
236236
description:
@@ -270,7 +270,7 @@ packages:
270270
path: "../packages/fwfh_selectable_text"
271271
relative: true
272272
source: path
273-
version: "0.8.2"
273+
version: "0.8.3"
274274
fwfh_svg:
275275
dependency: "direct overridden"
276276
description:
@@ -382,7 +382,7 @@ packages:
382382
name: lint
383383
url: "https://pub.dartlang.org"
384384
source: hosted
385-
version: "1.7.2"
385+
version: "1.8.1"
386386
logging:
387387
dependency: transitive
388388
description:
@@ -466,7 +466,7 @@ packages:
466466
name: path_provider
467467
url: "https://pub.dartlang.org"
468468
source: hosted
469-
version: "2.0.7"
469+
version: "2.0.8"
470470
path_provider_android:
471471
dependency: transitive
472472
description:
@@ -487,7 +487,7 @@ packages:
487487
name: path_provider_linux
488488
url: "https://pub.dartlang.org"
489489
source: hosted
490-
version: "2.1.2"
490+
version: "2.1.4"
491491
path_provider_macos:
492492
dependency: transitive
493493
description:
@@ -646,7 +646,7 @@ packages:
646646
name: sqflite_common
647647
url: "https://pub.dartlang.org"
648648
source: hosted
649-
version: "2.0.1+1"
649+
version: "2.1.0"
650650
stack_trace:
651651
dependency: transitive
652652
description:
@@ -884,7 +884,7 @@ packages:
884884
name: webview_flutter
885885
url: "https://pub.dartlang.org"
886886
source: hosted
887-
version: "2.8.0"
887+
version: "3.0.0"
888888
webview_flutter_android:
889889
dependency: transitive
890890
description:
@@ -905,7 +905,7 @@ packages:
905905
name: webview_flutter_wkwebview
906906
url: "https://pub.dartlang.org"
907907
source: hosted
908-
version: "2.7.0"
908+
version: "2.7.1"
909909
win32:
910910
dependency: transitive
911911
description:
@@ -935,5 +935,5 @@ packages:
935935
source: hosted
936936
version: "3.1.0"
937937
sdks:
938-
dart: ">=2.14.0 <3.0.0"
938+
dart: ">=2.15.0 <3.0.0"
939939
flutter: ">=2.5.0"

demo_app/test/golden_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void main() {
5151
'dev.flutter.pigeon.WebSettingsHostApi.setBuiltInZoomControls',
5252
'dev.flutter.pigeon.WebSettingsHostApi.setDisplayZoomControls',
5353
'dev.flutter.pigeon.WebSettingsHostApi.setDomStorageEnabled',
54+
// ignore: lines_longer_than_80_chars
5455
'dev.flutter.pigeon.WebSettingsHostApi.setJavaScriptCanOpenWindowsAutomatically',
5556
'dev.flutter.pigeon.WebSettingsHostApi.setJavaScriptEnabled',
5657
'dev.flutter.pigeon.WebSettingsHostApi.setLoadWithOverviewMode',

packages/core/analysis_options.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ linter:
1111
rules:
1212
always_put_control_body_on_new_line: true
1313
missing_whitespace_between_adjacent_strings: false
14+
15+
# relative vs. package imports
16+
always_use_package_imports: false
17+
avoid_relative_lib_imports: true
18+
prefer_relative_imports: true

packages/core/lib/src/core_data.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:fwfh_text_style/fwfh_text_style.dart';
44
import 'package:html/dom.dart' as dom;
55

66
import 'core_helpers.dart';
7-
import 'core_widget_factory.dart';
87

98
part 'data/build_bits.dart';
109
part 'data/css.dart';
@@ -42,7 +41,7 @@ abstract class BuildMetadata {
4241
///
4342
/// These are collected from:
4443
///
45-
/// - [WidgetFactory.parse] or [BuildOp.onChild] by calling `meta[key] = value`
44+
/// - [WidgetFactory.parse] or [BuildOp.onChild] via `meta[key] = value`
4645
/// - [BuildOp.defaultStyles] returning a map
4746
/// - Attribute `style` of [domElement]
4847
List<css.Declaration> get styles;
@@ -97,7 +96,7 @@ class BuildOp {
9796

9897
/// The callback that will be called whenver a child element is found.
9998
///
100-
/// Please note that all children and grandchildren etc. will trigger this method,
99+
/// Please note that all children and grandchildren etc. will trigger this,
101100
/// it's easy to check whether an element is direct child:
102101
///
103102
/// ```dart

packages/core/lib/src/core_helpers.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef CustomWidgetBuilder = Widget? Function(dom.Element element);
5252

5353
/// A callback to scroll the anchor identified by [id] into the viewport.
5454
///
55-
/// By default, an internal implementation is given to [WidgetFactory.onTapAnchor]
55+
/// By default, an internal impl is given to [WidgetFactory.onTapAnchor]
5656
/// when an anchor is tapped to handle the scrolling.
5757
/// A wf subclass can use this to change the [curve], the animation [duration]
5858
/// or even request scrolling to a different anchor.
@@ -266,9 +266,21 @@ Uint8List? bytesFromDataUri(String dataUri) {
266266
Iterable<T>? listOrNull<T>(T? x) => x == null ? null : [x];
267267

268268
/// Parses [key] from [map] as an double literal and return its value.
269-
double? tryParseDoubleFromMap(Map<dynamic, String> map, String key) =>
270-
map.containsKey(key) ? double.tryParse(map[key]!) : null;
269+
double? tryParseDoubleFromMap(Map<dynamic, String> map, String key) {
270+
final value = map[key];
271+
if (value == null) {
272+
return null;
273+
}
274+
275+
return double.tryParse(value);
276+
}
271277

272-
/// Parses [key] from [map] as a, possibly signed, integer literal and return its value.
273-
int? tryParseIntFromMap(Map<dynamic, String> map, String key) =>
274-
map.containsKey(key) ? int.tryParse(map[key]!) : null;
278+
/// Parses [key] from [map] as an integer literal and return its value.
279+
int? tryParseIntFromMap(Map<dynamic, String> map, String key) {
280+
final value = map[key];
281+
if (value == null) {
282+
return null;
283+
}
284+
285+
return int.tryParse(value);
286+
}

packages/core/lib/src/core_html_widget.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class HtmlWidget extends StatefulWidget {
5252

5353
/// The callback when user taps a link.
5454
///
55-
/// Returns `true` if the url has been handled, the default handler will be skipped.
55+
/// Returns `true` if the url has been handled,
56+
/// the default handler will be skipped.
5657
final FutureOr<bool> Function(String)? onTapUrl;
5758

5859
/// The values that should trigger rebuild.
@@ -81,8 +82,9 @@ class HtmlWidget extends StatefulWidget {
8182
/// The render mode.
8283
///
8384
/// - [RenderMode.column] is the default mode, suitable for small / medium document.
84-
/// - [RenderMode.listView] has better performance as it renders contents lazily.
85-
/// - [RenderMode.sliverList] has similar performance as `ListView` and can be put inside a `CustomScrollView`.
85+
/// - [RenderMode.listView] has better performance as it renders lazily.
86+
/// - [RenderMode.sliverList] has similar performance as `ListView`
87+
/// and can be put inside a `CustomScrollView`.
8688
final RenderMode renderMode;
8789

8890
/// The default styling for text elements.

packages/core/lib/src/core_widget_factory.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'internal/platform_specific/fallback.dart'
1616

1717
/// A factory to build widgets.
1818
class WidgetFactory {
19-
/// Setting this property to true replaces the default loading widget with a static [Text].
19+
/// Setting this property to true replaces the default with a static [Text].
2020
/// This property is most useful for testing purposes.
2121
///
2222
/// Defaults to `false`, resulting in a [CircularProgressIndicator].
@@ -49,7 +49,7 @@ class WidgetFactory {
4949

5050
/// Gets the current anchor registry.
5151
///
52-
/// This is an implementation detail and may be changed without a major version bump.
52+
/// This is an impl detail and may be changed without a major version bump.
5353
@protected
5454
AnchorRegistry get anchorRegistry => _anchorRegistry;
5555

packages/core/lib/src/data/css.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class CssBorder {
6868
radiusTopRight: other.radiusTopRight,
6969
);
7070

71-
/// Creates a copy of this border but with the given fields replaced with the new values.
71+
/// Creates a copy of this border but with the given fields
72+
/// replaced with the new values.
7273
CssBorder copyWith({
7374
CssBorderSide? bottom,
7475
CssBorderSide? inlineEnd,
@@ -399,11 +400,11 @@ enum CssLengthUnit {
399400
/// The whitespace behavior.
400401
enum CssWhitespace {
401402
/// Sequences of white space are collapsed.
402-
/// Newline characters in the source are handled the same as other white space.
403+
/// Newline characters in the source are handled the same as other whitespace.
403404
/// Lines are broken as necessary to fill line boxes.
404405
normal,
405406

406407
/// Sequences of white space are preserved.
407-
/// Lines are only broken at newline characters in the source and at <br> elements.
408+
/// Lines are only broken at newline characters in the source and at `BR`s.
408409
pre,
409410
}

packages/core/lib/src/data/text_style.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TextStyleHtml {
6262
}) {
6363
assert(
6464
style is FwfhTextStyle?,
65-
'The text style should be modified by calling methods of the existing instance: '
65+
'The text style should be modified by methods of the existing instance: '
6666
'apply(), copyWith() or merge().',
6767
);
6868

@@ -138,6 +138,7 @@ class TextStyleBuilder<T1> {
138138
final l = _builders!.length;
139139
for (var i = 0; i < l; i++) {
140140
final builder = _builders![i];
141+
// ignore: avoid_dynamic_calls
141142
_output = builder(_output, _inputs![i]) as TextStyleHtml;
142143
assert(_output?.parent == _parentOutput);
143144
}

packages/core/lib/src/external/csslib.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension DomElementExtension on dom.Element {
1414
/// This is different from [BuildMetadata.styles] as it doesn't include
1515
/// runtime additions from [WidgetFactory] or [BuildOp]s.
1616
///
17-
/// Parsing CSS is a non-trivial task but the result is cached for each element
17+
/// Parsing CSS is a non-trivial task but the result is cached
1818
/// so it's safe to call this again and again.
1919
List<css.Declaration> get styles {
2020
final expando = _expando ??= Expando();

packages/core/lib/src/internal/ops/tag_li.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TagLi {
3232
late final BuildOp _itemOp;
3333
final _itemWidgets = <WidgetPlaceholder>[];
3434

35-
_ListConfig? _config;
35+
_ListConfig? __config;
3636

3737
TagLi(this.wf, this.listMeta) {
3838
op = _TagLiListOp(this);
@@ -49,10 +49,10 @@ class TagLi {
4949
);
5050
}
5151

52-
_ListConfig get config {
52+
_ListConfig get _config {
5353
// cannot build config from constructor because
5454
// inline styles are not fully parsed at that time
55-
return _config ??= _ListConfig.fromBuildMetadata(listMeta);
55+
return __config ??= _ListConfig.fromBuildMetadata(listMeta);
5656
}
5757

5858
Map<String, String> defaultStyles(dom.Element element) {
@@ -92,6 +92,7 @@ class TagLi {
9292
}
9393

9494
Widget _buildItem(BuildContext context, Widget child, int i) {
95+
final config = _config;
9596
final meta = _itemMetas[i];
9697
final listStyleType = _ListConfig.listStyleTypeFromBuildMetadata(meta) ??
9798
config.listStyleType;

0 commit comments

Comments
 (0)