@@ -19,10 +19,10 @@ import 'package:url_launcher/url_launcher.dart';
19
19
extension IterableExt <T > on Iterable <T >? {
20
20
bool get isNullOrEmpty => this == null || this ! .isEmpty;
21
21
22
- bool get isSafeNotEmpty => ! this . isNullOrEmpty;
22
+ bool get isSafeNotEmpty => ! isNullOrEmpty;
23
23
24
24
T ? getOrNull (final int index) {
25
- if (this . isNullOrEmpty) return null ;
25
+ if (isNullOrEmpty) return null ;
26
26
return this ! .elementAt (index);
27
27
}
28
28
@@ -35,7 +35,7 @@ extension IterableExt<T> on Iterable<T>? {
35
35
return true ;
36
36
}
37
37
38
- bool ne (Iterable <T > other) => ! this . eq (other);
38
+ bool ne (Iterable <T > other) => ! eq (other);
39
39
}
40
40
41
41
extension BoolExt on bool {
@@ -45,10 +45,10 @@ extension BoolExt on bool {
45
45
extension ListExt <T > on List <T >? {
46
46
bool get isNullOrEmpty => this == null || this ! .isEmpty;
47
47
48
- bool get isSafeNotEmpty => ! this . isNullOrEmpty;
48
+ bool get isSafeNotEmpty => ! isNullOrEmpty;
49
49
50
50
T ? getOrNull (final int index) {
51
- if (this . isNullOrEmpty) return null ;
51
+ if (isNullOrEmpty) return null ;
52
52
return this ! [index];
53
53
}
54
54
@@ -61,13 +61,13 @@ extension ListExt<T> on List<T>? {
61
61
return true ;
62
62
}
63
63
64
- bool ne (List <T >? other) => ! this . eq (other);
64
+ bool ne (List <T >? other) => ! eq (other);
65
65
}
66
66
67
67
extension MapExt <K , V > on Map <K , V >? {
68
68
bool get isNullOrEmpty => this == null || this ! .isEmpty;
69
69
70
- bool get isSafeNotEmpty => ! this . isNullOrEmpty;
70
+ bool get isSafeNotEmpty => ! isNullOrEmpty;
71
71
72
72
bool eq (Map <K , V >? other) {
73
73
if (this == null ) return other == null ;
@@ -80,7 +80,7 @@ extension MapExt<K, V> on Map<K, V>? {
80
80
return true ;
81
81
}
82
82
83
- bool ne (Map <K , V >? other) => ! this . eq (other);
83
+ bool ne (Map <K , V >? other) => ! eq (other);
84
84
}
85
85
86
86
extension NullableStringExt on String ? {
@@ -91,7 +91,7 @@ extension NullableStringExt on String? {
91
91
bool get isNotBlank => this != null && ! this ! .isBlank;
92
92
93
93
toast () async {
94
- if (this . isNullOrBlank) {
94
+ if (isNullOrBlank) {
95
95
return ;
96
96
}
97
97
showToastWidget (
@@ -114,7 +114,7 @@ extension NullableStringExt on String? {
114
114
boxShadow: [
115
115
BoxShadow (
116
116
color: Colors .black.withOpacity (0.024 ),
117
- offset: Offset (0 , 1 ),
117
+ offset: const Offset (0 , 1 ),
118
118
blurRadius: 3.0 ,
119
119
spreadRadius: 3.0 ,
120
120
),
@@ -136,7 +136,7 @@ extension NullableStringExt on String? {
136
136
}
137
137
138
138
launchAppAndCopy () async {
139
- if (this . isNullOrBlank) return "内容为空,取消操作" .toast ();
139
+ if (isNullOrBlank) return "内容为空,取消操作" .toast ();
140
140
Future _doOtherAction () async {
141
141
if (await canLaunch (this ! )) {
142
142
await launch (this ! );
@@ -163,24 +163,24 @@ extension NullableStringExt on String? {
163
163
}
164
164
165
165
copy () {
166
- if (this . isNullOrBlank) return "内容为空,取消操作" .toast ();
166
+ if (isNullOrBlank) return "内容为空,取消操作" .toast ();
167
167
FlutterClipboard .copy (this ! ).then ((_) => "成功复制到剪切板" .toast ());
168
168
}
169
169
170
170
share () {
171
- if (this . isNullOrBlank) return "内容为空,取消操作" .toast ();
171
+ if (isNullOrBlank) return "内容为空,取消操作" .toast ();
172
172
Share .share (this ! );
173
173
FlutterClipboard .copy (this ! ).then ((_) => "尝试分享,并复制到剪切板" .toast ());
174
174
}
175
175
}
176
176
177
177
extension StringExt on String {
178
178
bool get isBlank {
179
- if (this . length == 0 ) {
179
+ if (length == 0 ) {
180
180
return true ;
181
181
}
182
- for (var value in this . runes) {
183
- if (! this . _isWhitespace (value)) {
182
+ for (int value in runes) {
183
+ if (! _isWhitespace (value)) {
184
184
return false ;
185
185
}
186
186
}
@@ -203,8 +203,8 @@ extension StringExt on String {
203
203
rune == 0xFEFF ;
204
204
205
205
String fillChar (String value, String char) {
206
- var offset = value.length - this . length;
207
- var newVal = this ;
206
+ int offset = value.length - length;
207
+ String newVal = this ;
208
208
if (offset > 0 ) {
209
209
for (int i = 0 ; i < offset; i++ ) {
210
210
newVal = char + newVal;
@@ -351,12 +351,16 @@ Iterable<String> _debugWordWrap(String message, int width,
351
351
switch (mode) {
352
352
case _WordWrapParseMode
353
353
.inSpace: // at start of break point (or start of line); can't break until next break
354
- while ((index < message.length) && (message[index] == ' ' )) index += 1 ;
354
+ while ((index < message.length) && (message[index] == ' ' )) {
355
+ index += 1 ;
356
+ }
355
357
lastWordStart = index;
356
358
mode = _WordWrapParseMode .inWord;
357
359
break ;
358
360
case _WordWrapParseMode .inWord: // looking for a good break point
359
- while ((index < message.length) && (message[index] != ' ' )) index += 1 ;
361
+ while ((index < message.length) && (message[index] != ' ' )) {
362
+ index += 1 ;
363
+ }
360
364
mode = _WordWrapParseMode .atBreak;
361
365
break ;
362
366
case _WordWrapParseMode .atBreak: // at start of break point
@@ -380,8 +384,9 @@ Iterable<String> _debugWordWrap(String message, int width,
380
384
if (lastWordEnd == index) {
381
385
// we broke at current position
382
386
// eat all the spaces, then set our start point
383
- while ((index < message.length) && (message[index] == ' ' ))
387
+ while ((index < message.length) && (message[index] == ' ' )) {
384
388
index += 1 ;
389
+ }
385
390
start = index;
386
391
mode = _WordWrapParseMode .inWord;
387
392
} else {
@@ -406,22 +411,22 @@ Iterable<String> _debugWordWrap(String message, int width,
406
411
407
412
extension RefreshControllerExt on RefreshController {
408
413
completed ({bool noMore = false }) {
409
- if (this . isRefresh) {
410
- this . refreshCompleted ();
411
- } else if (this . isLoading) {
414
+ if (isRefresh) {
415
+ refreshCompleted ();
416
+ } else if (isLoading) {
412
417
if (noMore) {
413
- this . loadNoData ();
418
+ loadNoData ();
414
419
} else {
415
- this . loadComplete ();
420
+ loadComplete ();
416
421
}
417
422
}
418
423
}
419
424
420
425
failed () {
421
- if (this . isRefresh) {
422
- this . refreshFailed ();
423
- } else if (this . isLoading) {
424
- this . loadFailed ();
426
+ if (isRefresh) {
427
+ refreshFailed ();
428
+ } else if (isLoading) {
429
+ loadFailed ();
425
430
}
426
431
}
427
432
}
@@ -498,14 +503,14 @@ extension BrightnessColor on Color {
498
503
499
504
extension ColorExt on Color {
500
505
bool get isDark {
501
- return this . computeLuminance () < 0.5 ;
506
+ return computeLuminance () < 0.5 ;
502
507
}
503
508
}
504
509
505
510
extension ThemeDataExt on ThemeData {
506
- Color get primary => this . colorScheme.primary;
511
+ Color get primary => colorScheme.primary;
507
512
508
- Color get secondary => this . colorScheme.secondary;
513
+ Color get secondary => colorScheme.secondary;
509
514
}
510
515
511
516
eee () {}
0 commit comments