Skip to content

Commit

Permalink
clean lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed Apr 30, 2024
1 parent 394e99d commit ff004bd
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 15 deletions.
10 changes: 5 additions & 5 deletions packages/you_flutter/lib/src/layouts/page_layout_default.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PageLayoutDefault extends StatelessWidget {
final PageBuilder builder;
final ToUri uri;

PageLayoutDefault({required this.builder, required this.uri});
const PageLayoutDefault({super.key, required this.builder, required this.uri});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -35,7 +35,7 @@ class PageLayoutDefault extends StatelessWidget {
rail(title: "文件夹", icon: Icons.folder_outlined),
rail(title: "文件夹2", icon: Icons.folder_outlined),
]),
Drawer(
const Drawer(
width: 200,
child: _RouteTree(),
),
Expand All @@ -60,16 +60,16 @@ class _RouteTree extends StatelessWidget {
String title = "▼ ${node.part}";
title = title.padLeft((node.level * 3) + title.length);

var click = () {
click() {
router.to(node.toUri());
};
}
return Align(
alignment: Alignment.centerLeft,
child: TextButton(onPressed: click, child: Text(title)),
);
});
return ConstrainedBox(
constraints: BoxConstraints.tightFor(width: 350),
constraints: const BoxConstraints.tightFor(width: 350),
child: ListView(
children: [
...routeWidgets,
Expand Down
10 changes: 8 additions & 2 deletions packages/you_flutter/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:collection';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path_;
import 'package:you_flutter/src/layouts/page_layout_default.dart';
import 'package:you_flutter/src/log.dart';
Expand Down Expand Up @@ -79,6 +80,7 @@ class RouteContext with RouterMixin {
final YouRouter router;
final ToUri uri;
}

/// TODO P1 应针对2种flutter 支持的route模式进行适配:
/// path base: https://example.com/product/1
/// fragment base: https://example.com/base-harf/#/product/1
Expand All @@ -100,6 +102,7 @@ class YouRouter with RouterMixin {
);
}

@override
final To root;
final GlobalKey<NavigatorState> _navigatorKey;
late final RouterConfig<Object> _config;
Expand Down Expand Up @@ -189,6 +192,9 @@ base class To {

To get parent => _parent;

@mustBeOverridden
bool get isValid => _builder != null;

static PageBuilder? _asyncToSync(LazyPageBuilder? builder) {
if (builder == null) {
return null;
Expand Down Expand Up @@ -223,7 +229,7 @@ base class To {
/// return Strictly equal ancestors of type
Iterable<T> findAncestorsOfSameType<T>() sync* {
for (var a in ancestors) {
if (a.runtimeType == this.runtimeType) {
if (a.runtimeType == runtimeType) {
yield a as T;
}
}
Expand Down Expand Up @@ -378,7 +384,7 @@ ${" " * level}</Route>''';
// FIXME NotFoundError如何处理
throw NotFoundError(invalidValue: uri);
}
final List<To> chain=[this,...findAncestorsOfSameType<To>()];
final List<To> chain = [this, ...findAncestorsOfSameType<To>()];

for (var i in chain) {
if (i._layout != null) return i._layout(context, _builder);
Expand Down
2 changes: 2 additions & 0 deletions packages/you_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dev_dependencies:
flutter_test:
sdk: flutter
checks: ^0.3.0
flutter_lints: ^3.0.2


dependency_overrides:
# dart CHANGELOG 3.0.0 2023-05-10
Expand Down
4 changes: 4 additions & 0 deletions packages/you_note_dart/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:you_note_dart/src/contents/outline.dart';
class MD extends StatelessWidget {
final String text;

const MD(this.text, {Object? debugLabel});
const MD(this.text, {super.key, Object? debugLabel});

@override
Widget build(BuildContext context) {
Expand Down
10 changes: 5 additions & 5 deletions packages/you_note_dart/lib/src/layouts/note_layout_style_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:you_note_dart/src/note.dart';
final class NoteLayoutStyle1 extends StatelessWidget {
final NoteBuilder builder;

NoteLayoutStyle1({super.key, required this.builder});
const NoteLayoutStyle1({super.key, required this.builder});

@override
Widget build(BuildContext context) {
Expand All @@ -32,7 +32,7 @@ final class NoteLayoutStyle1 extends StatelessWidget {
return Row(
children: [
// IntrinsicWidth(child: _NoteTreeView(uri)),
_NoteTreeView(),
const _NoteTreeView(),
Flexible(child: ListView(children: pageContents)),
],
);
Expand All @@ -55,16 +55,16 @@ class _NoteTreeView extends StatelessWidget {
String title = "▼ ${node.part}";
title = title.padLeft((node.level * 3) + title.length);

var click = () {
click() {
router.to(node.toUri());
};
}
return Align(
alignment: Alignment.centerLeft,
child: TextButton(onPressed: click , child: Text(title)),
);
});
return ConstrainedBox(
constraints: BoxConstraints.tightFor(width: 350),
constraints: const BoxConstraints.tightFor(width: 350),
child: ListView(
children: [...routeWidgets],
));
Expand Down
5 changes: 5 additions & 0 deletions packages/you_note_dart/lib/src/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ base class ToNote extends To {
_layout = layout,
super(children: children);

@override
bool get isValid => _builder!=null;

@override
Widget build(BuildContext context, ToUri uri) {
if (_builder == null) {
// TODO not found
Expand All @@ -34,6 +38,7 @@ base class ToNote extends To {
}
return NoteLayoutDefault(uri: uri, builder: _builder);
}

}

@Deprecated("已被you_router取代,待删除")
Expand Down
1 change: 1 addition & 0 deletions packages/you_note_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies:
# you_*
you_dart: ^0.0.4
you_flutter: ^0.0.4
flutter_lints: ^3.0.2

# async: ^2.11.0
dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
for (var _ in List.generate(100, (i) => i)) {
var parseResult = parseString(content: file.readAsStringSync(), featureSet: FeatureSet.latestLanguageVersion());
var unit = parseResult.unit;
unit.visitChildren(GeneralizingAstVisitor());
unit.visitChildren(const GeneralizingAstVisitor());
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:you_note_dart/src/note.dart';

final _emptyJsonMap = '{"version":3,"sources":[],"mappings":""}';
const _emptyJsonMap = '{"version":3,"sources":[],"mappings":""}';

void main() {
group("jsSourceMap", () {
Expand Down

0 comments on commit ff004bd

Please sign in to comment.