Skip to content

Commit d5cf274

Browse files
authored
Dead code removal 2 (#78)
* fix: remove dead code from kit/ and InstanceDialog Remove unused code identified by deep scan: - Delete kit/core/func.dart (Fns.throttle unused) - Delete kit/core/build.dart (BuildMode unused after dprint removal) - Delete kit/core/ext/string.dart (StringX.launchUrl unused) - Remove dprint/lprint and unused Loggers.root/store/route/app from logger.dart - Remove nullOr() extension and nvn() function from obj.dart - Remove RNodeX.listen(), ValBuilder, listenVal(), EmptyListenable, RNodes from rnode.dart - Remove WindowFrameConfig.setShowCaption() (never called) - Remove unused platform constants: isAndroid, isIOS, isWeb, isMobile - Remove ~20 unused UIs style constants (keep textGrey, textRed, text15, placeholder, height13) - Remove InstanceDialog.onSave parameter and dead branch in _submit - Clean up barrel exports in kit.dart * perf: optimize sort comparator and fix empty setState callbacks Performance: - Extract _statusOrder Map to static const (avoids allocation per comparison) - Extract _compareIgnoreCase helper for case-insensitive sort Code quality: - Move _pruneSelection mutation inside setState callback - Move peers fetch state mutations inside setState in task_details_dialog - Remove no-op empty setState in instance_dialog host/port onChange handlers * fix: peers fetch setState after dispose and isLoadingPeers leak - Replace early return on instance==null with local error variable - Move setState into finally block with context.mounted guard - Use local peersResult/peersErrorLocal to avoid duplicated setState
1 parent 1a43f8f commit d5cf274

14 files changed

Lines changed: 48 additions & 246 deletions

File tree

lib/kit/core/build.dart

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/kit/core/ext/obj.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,5 @@ extension ObjectX<T extends Object> on T {
55
}
66

77
extension ObjectXNullable<T extends Object> on T? {
8-
A? nullOr<A>(A Function(T) f) => this != null ? f(this!) : null;
9-
108
VNode<T?> get vn => VNode<T?>(this);
119
}
12-
13-
VNode<T?> nvn<T>() => VNode<T?>(null);

lib/kit/core/ext/string.dart

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/kit/core/func.dart

Lines changed: 0 additions & 23 deletions
This file was deleted.

lib/kit/core/logger.dart

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
import 'dart:io';
22

3-
import 'package:logging/logging.dart';
4-
5-
import 'build.dart';
6-
73
abstract final class Loggers {
8-
static final root = Logger('Root');
9-
static final store = Logger('Store');
10-
static final route = Logger('Route');
11-
static final app = Logger('App');
12-
134
static final sourceReg = RegExp(r'\((.+):(\d+):(\d+)\)');
145

156
static void log(Object message, {int skipFrames = 1}) {
@@ -35,31 +26,3 @@ abstract final class Loggers {
3526
print(message);
3627
}
3728
}
38-
39-
void dprint(Object? msg, [Object? msg2, Object? msg3, Object? msg4]) {
40-
if (!BuildMode.isDebug) return;
41-
lprint(msg, msg2, msg3, msg4, 3);
42-
}
43-
44-
void lprint(
45-
Object? msg, [
46-
Object? msg2,
47-
Object? msg3,
48-
Object? msg4,
49-
int skipFrames = 2,
50-
]) {
51-
final sb = StringBuffer();
52-
sb.write(msg.toString());
53-
54-
if (msg2 != null) {
55-
sb.write('\n$msg2');
56-
if (msg3 != null) {
57-
sb.write('\n$msg3');
58-
if (msg4 != null) {
59-
sb.write('\n$msg4');
60-
}
61-
}
62-
}
63-
final str = sb.toString();
64-
Loggers.log(str, skipFrames: skipFrames);
65-
}

lib/kit/core/platform.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ enum Pfs {
3838
}();
3939
}
4040

41-
final isAndroid = Pfs.type == Pfs.android;
42-
final isIOS = Pfs.type == Pfs.ios;
4341
final isLinux = Pfs.type == Pfs.linux;
4442
final isMacOS = Pfs.type == Pfs.macos;
4543
final isWindows = Pfs.type == Pfs.windows;
46-
final isWeb = Pfs.type == Pfs.web;
47-
final isMobile = Pfs.type == Pfs.ios || Pfs.type == Pfs.android;
4844
final isDesktop =
4945
Pfs.type == Pfs.linux || Pfs.type == Pfs.macos || Pfs.type == Pfs.windows;

lib/kit/core/rnode.dart

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class RNode implements ChangeNotifier {
5050
}
5151
}
5252

53-
extension RNodeX on RNode {
54-
ListenBuilder listen(Widget Function() builder) {
55-
return ListenBuilder(listenable: this, builder: builder);
56-
}
57-
}
58-
5953
class VNode<T> extends RNode implements ValueNotifier<T> {
6054
T _value;
6155

@@ -74,45 +68,3 @@ class VNode<T> extends RNode implements ValueNotifier<T> {
7468
@override
7569
String toString() => 'VNode($value)';
7670
}
77-
78-
extension ValueListenableX<T> on ValueListenable<T> {
79-
ValBuilder<T> listenVal(Widget Function(T) builder) {
80-
return ValBuilder<T>(listenable: this, builder: builder);
81-
}
82-
}
83-
84-
final class ValBuilder<T> extends ValueListenableBuilder<T> {
85-
final ValueListenable<T> listenable;
86-
87-
ValBuilder({
88-
super.key,
89-
required this.listenable,
90-
required Widget Function(T) builder,
91-
}) : super(valueListenable: listenable, builder: (_, val, _) => builder(val));
92-
}
93-
94-
final class ListenBuilder extends ListenableBuilder {
95-
ListenBuilder({
96-
super.key,
97-
required super.listenable,
98-
required Widget Function() builder,
99-
}) : super(builder: (_, _) => builder());
100-
}
101-
102-
final class EmptyListenable<T> implements ValueListenable<T?> {
103-
@override
104-
void addListener(VoidCallback listener) {}
105-
106-
@override
107-
void removeListener(VoidCallback listener) {}
108-
109-
@override
110-
T? get value => null;
111-
112-
const EmptyListenable();
113-
}
114-
115-
abstract final class RNodes {
116-
static final app = RNode();
117-
static final dark = VNode<bool>(false);
118-
}

lib/kit/kit.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
library;
22

3-
export 'core/build.dart';
43
export 'core/ext/datetime.dart';
54
export 'core/ext/obj.dart';
6-
export 'core/ext/string.dart';
75
export 'core/ext/widget.dart';
8-
export 'core/func.dart';
96
export 'core/logger.dart';
107
export 'core/platform.dart';
118
export 'core/rnode.dart';

lib/kit/res/ui.dart

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,10 @@
11
import 'package:flutter/material.dart';
22

33
abstract final class UIs {
4-
static const text11 = TextStyle(fontSize: 11);
5-
static const text11Bold = TextStyle(
6-
fontSize: 11,
7-
fontWeight: FontWeight.w500,
8-
);
9-
static const text11Grey = TextStyle(color: Colors.grey, fontSize: 11);
10-
static const text12 = TextStyle(fontSize: 12);
11-
static const text12Bold = TextStyle(
12-
fontSize: 12,
13-
fontWeight: FontWeight.bold,
14-
);
15-
static const text12Grey = TextStyle(color: Colors.grey, fontSize: 12);
16-
static const text13 = TextStyle(fontSize: 13);
17-
static const text13Bold = TextStyle(
18-
fontSize: 13,
19-
fontWeight: FontWeight.bold,
20-
);
21-
static const text13Grey = TextStyle(color: Colors.grey, fontSize: 13);
224
static const text15 = TextStyle(fontSize: 15);
23-
static const text15Bold = TextStyle(
24-
fontSize: 15,
25-
fontWeight: FontWeight.bold,
26-
);
27-
static const text18 = TextStyle(fontSize: 18);
28-
static const text27 = TextStyle(fontSize: 27);
295
static const textGrey = TextStyle(color: Colors.grey);
306
static const textRed = TextStyle(color: Colors.red);
317

328
static const placeholder = SizedBox();
33-
static const height7 = SizedBox(height: 7);
349
static const height13 = SizedBox(height: 13);
35-
static const height77 = SizedBox(height: 77);
36-
static const width7 = SizedBox(width: 7);
37-
static const width13 = SizedBox(width: 13);
38-
39-
static Widget dot({Color? color, double? size}) => Container(
40-
width: size ?? 7,
41-
height: size ?? 7,
42-
decoration: BoxDecoration(
43-
color: color ?? primaryColor,
44-
shape: BoxShape.circle,
45-
),
46-
);
47-
48-
static const centerLoading = Padding(
49-
padding: EdgeInsets.symmetric(vertical: 7),
50-
child: Center(child: CircularProgressIndicator()),
51-
);
52-
53-
static var colorSeed = const Color.fromARGB(255, 72, 15, 15);
54-
static var primaryColor = colorSeed;
5510
}

lib/kit/widgets/virtual_window_frame.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import '../core/platform.dart';
55
import 'appbar.dart';
66

77
abstract final class WindowFrameConfig {
8-
static bool _showCaption = true;
9-
10-
static bool get showCaption => _showCaption && isDesktop;
11-
12-
static void setShowCaption(bool value) {
13-
_showCaption = value;
14-
}
8+
static bool get showCaption => isDesktop;
159
}
1610

1711
class VirtualWindowFrame extends StatelessWidget {

0 commit comments

Comments
 (0)