Skip to content

Commit 38dcf5d

Browse files
committed
print
1 parent a3858c0 commit 38dcf5d

Some content is hidden

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

43 files changed

+300
-151
lines changed

analysis_options.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ analyzer:
66

77
linter:
88
rules:
9-
non_constant_identifier_names: false
9+
non_constant_identifier_names: false
10+
file_names: false
11+
constant_identifier_names: false
12+
library_private_types_in_public_api: false

lib/common/dao/dao_result.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class DataResult {
2-
var data;
2+
Object? data;
33
bool result;
44
Function? next;
55

lib/common/dao/repos_dao.dart

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:io';
44

55
import 'package:built_value/serializer.dart';
66
import 'package:dio/dio.dart';
7+
import 'package:flutter/foundation.dart';
78
import 'package:fluttertoast/fluttertoast.dart';
89
import 'package:gsy_github_app_flutter/common/localization/default_localizations.dart';
910
import 'package:gsy_github_app_flutter/common/net/graphql/client.dart';
@@ -509,7 +510,9 @@ class ReposDao {
509510

510511
/// 反序列化
511512
Map result = serializers.serializeWith(serializerForType, test) as Map<dynamic, dynamic>;
512-
print("###### $test $result");
513+
if (kDebugMode) {
514+
print("###### $test $result");
515+
}
513516

514517
list.add(data['name']);
515518
}
@@ -678,23 +681,31 @@ class ReposDao {
678681
String? versionName = release.name;
679682
if (versionName != null) {
680683
if (Config.DEBUG!) {
681-
print("versionName $versionName");
684+
if (kDebugMode) {
685+
print("versionName $versionName");
686+
}
682687
}
683688

684689
PackageInfo packageInfo = await PackageInfo.fromPlatform();
685690
var appVersion = packageInfo.version;
686691

687692
if (Config.DEBUG!) {
688-
print("appVersion $appVersion");
693+
if (kDebugMode) {
694+
print("appVersion $appVersion");
695+
}
689696
}
690697
Version versionNameNum = Version.parse(versionName);
691698
Version currentNum = Version.parse(appVersion);
692699
int result = versionNameNum.compareTo(currentNum);
693700
if (Config.DEBUG!) {
694-
print("versionNameNum $versionNameNum currentNum $currentNum");
701+
if (kDebugMode) {
702+
print("versionNameNum $versionNameNum currentNum $currentNum");
703+
}
695704
}
696705
if (Config.DEBUG!) {
697-
print("newsHad $result");
706+
if (kDebugMode) {
707+
print("newsHad $result");
708+
}
698709
}
699710
if (result > 0) {
700711
CommonUtils.showUpdateDialog(
@@ -727,7 +738,9 @@ class ReposDao {
727738
}
728739
}
729740
} catch (e) {
730-
print(e);
741+
if (kDebugMode) {
742+
print(e);
743+
}
731744
}
732745
}
733746
return DataResult(null, false);

lib/common/dao/user_dao.dart

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:convert';
22
import 'package:dio/dio.dart';
3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/material.dart';
45
import 'package:gsy_github_app_flutter/common/net/graphql/client.dart';
56
import 'package:gsy_github_app_flutter/db/provider/user/user_followed_db_provider.dart';
@@ -44,9 +45,11 @@ class UserDao {
4445

4546
resultData = await getUserInfo(null);
4647
if (Config.DEBUG!) {
47-
print("user result ${resultData.result}");
48-
print(resultData.data);
49-
print(res.data.toString());
48+
if (kDebugMode) {
49+
print("user result ${resultData.result}");
50+
print(resultData.data);
51+
print(res.data.toString());
52+
}
5053
}
5154
if (resultData.result == true) {
5255
store.dispatch(UpdateUserAction(resultData.data));
@@ -61,7 +64,9 @@ class UserDao {
6164
var bytes = utf8.encode(type);
6265
var base64Str = base64.encode(bytes);
6366
if (Config.DEBUG!) {
64-
print("base64Str login $base64Str");
67+
if (kDebugMode) {
68+
print("base64Str login $base64Str");
69+
}
6570
}
6671

6772
await LocalStorage.save(Config.USER_NAME_KEY, userName);
@@ -82,9 +87,11 @@ class UserDao {
8287
await LocalStorage.save(Config.PW_KEY, password);
8388
var resultData = await getUserInfo(null);
8489
if (Config.DEBUG!) {
85-
print("user result ${resultData.result}");
86-
print(resultData.data);
87-
print(res.data.toString());
90+
if (kDebugMode) {
91+
print("user result ${resultData.result}");
92+
print(resultData.data);
93+
print(res.data.toString());
94+
}
8895
}
8996
store.dispatch(UpdateUserAction(resultData.data));
9097
}
@@ -133,7 +140,7 @@ class UserDao {
133140
static getUserInfo(userName, {needDb = false}) async {
134141
UserInfoDbProvider provider = UserInfoDbProvider();
135142
next() async {
136-
var res;
143+
dynamic res;
137144
if (userName == null) {
138145
res = await httpManager.netFetch(
139146
Address.getMyUserInfo(), null, null, null);
@@ -198,7 +205,9 @@ class UserDao {
198205
}
199206
}
200207
} catch (e) {
201-
print(e);
208+
if (kDebugMode) {
209+
print(e);
210+
}
202211
}
203212
}
204213
return DataResult(null, false);

lib/common/event/http_error_event.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// Created by guoshuyu
22
/// Date: 2018-08-16
3+
library;
34

45
class HttpErrorEvent {
56
final int? code;

lib/common/net/interceptors/log_interceptor.dart

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore_for_file: type_literal_in_constant_pattern
22

33
import 'package:dio/dio.dart';
4+
import 'package:flutter/foundation.dart';
45
import 'package:gsy_github_app_flutter/common/config/config.dart';
56

67
/// Log 拦截器
@@ -19,16 +20,22 @@ class LogsInterceptors extends InterceptorsWrapper {
1920
@override
2021
onRequest(RequestOptions options, handler) async {
2122
if (Config.DEBUG!) {
22-
print("请求url:${options.path} ${options.method}");
23+
if (kDebugMode) {
24+
print("请求url:${options.path} ${options.method}");
25+
}
2326
options.headers.forEach((k, v) => options.headers[k] = v ?? "");
24-
print('请求头: ${options.headers}');
27+
if (kDebugMode) {
28+
print('请求头: ${options.headers}');
29+
}
2530
if (options.data != null) {
26-
print('请求参数: ${options.data}');
31+
if (kDebugMode) {
32+
print('请求参数: ${options.data}');
33+
}
2734
}
2835
}
2936
try {
3037
addLogic(sRequestHttpUrl, options.path);
31-
var data;
38+
dynamic data;
3239
if (options.data is Map) {
3340
data = options.data;
3441
} else {
@@ -42,15 +49,19 @@ class LogsInterceptors extends InterceptorsWrapper {
4249
}
4350
addLogic(sHttpRequest, map);
4451
} catch (e) {
45-
print(e);
52+
if (kDebugMode) {
53+
print(e);
54+
}
4655
}
4756
return super.onRequest(options, handler);
4857
}
4958

5059
@override
5160
onResponse(Response response, handler) async {
5261
if (Config.DEBUG!) {
53-
print('返回参数: $response');
62+
if (kDebugMode) {
63+
print('返回参数: $response');
64+
}
5465
}
5566
switch (response.data.runtimeType) {
5667
case Map || List:
@@ -61,7 +72,9 @@ class LogsInterceptors extends InterceptorsWrapper {
6172
addLogic(sResponsesHttpUrl, response.requestOptions.uri.toString());
6273
addLogic(sHttpResponses, data);
6374
} catch (e) {
64-
print(e);
75+
if (kDebugMode) {
76+
print(e);
77+
}
6578
}
6679
}
6780
case String:
@@ -72,7 +85,9 @@ class LogsInterceptors extends InterceptorsWrapper {
7285
addLogic(sResponsesHttpUrl, response.requestOptions.uri.toString());
7386
addLogic(sHttpResponses, data);
7487
} catch (e) {
75-
print(e);
88+
if (kDebugMode) {
89+
print(e);
90+
}
7691
}
7792
}
7893
}
@@ -82,16 +97,20 @@ class LogsInterceptors extends InterceptorsWrapper {
8297
@override
8398
onError(DioException err, handler) async {
8499
if (Config.DEBUG!) {
85-
print('请求异常: $err');
86-
print('请求异常信息: ${err.response?.toString() ?? ""}');
100+
if (kDebugMode) {
101+
print('请求异常: $err');
102+
print('请求异常信息: ${err.response?.toString() ?? ""}');
103+
}
87104
}
88105
try {
89106
addLogic(sHttpErrorUrl, err.requestOptions.path);
90107
var errors = <String, dynamic>{};
91108
errors["error"] = err.message;
92109
addLogic(sHttpError, errors);
93110
} catch (e) {
94-
print(e);
111+
if (kDebugMode) {
112+
print(e);
113+
}
95114
}
96115
return super.onError(err, handler);
97116
}

lib/common/net/interceptors/response_interceptor.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:dio/dio.dart';
2+
import 'package:flutter/foundation.dart';
23
import 'package:gsy_github_app_flutter/common/net/code.dart';
34
import 'package:gsy_github_app_flutter/common/net/result_data.dart';
45

@@ -9,7 +10,7 @@ class ResponseInterceptors extends InterceptorsWrapper {
910
@override
1011
onResponse(Response response, handler) async {
1112
RequestOptions option = response.requestOptions;
12-
var value;
13+
dynamic value;
1314
try {
1415
var header = response.headers[Headers.contentTypeHeader];
1516
if ((header != null && header.toString().contains("text"))) {
@@ -19,7 +20,9 @@ class ResponseInterceptors extends InterceptorsWrapper {
1920
headers: response.headers);
2021
}
2122
} catch (e) {
22-
print(e.toString() + option.path);
23+
if (kDebugMode) {
24+
print(e.toString() + option.path);
25+
}
2326
value = ResultData(response.data, false, response.statusCode,
2427
headers: response.headers);
2528
}

lib/common/net/interceptors/token_interceptor.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:dio/dio.dart';
2+
import 'package:flutter/foundation.dart';
23
import 'package:gsy_github_app_flutter/common/config/config.dart';
34
import 'package:gsy_github_app_flutter/common/local/local_storage.dart';
45
import 'package:gsy_github_app_flutter/common/net/graphql/client.dart';
@@ -34,7 +35,9 @@ class TokenInterceptors extends InterceptorsWrapper {
3435
await LocalStorage.save(Config.TOKEN_KEY, _token);
3536
}
3637
} catch (e) {
37-
print(e);
38+
if (kDebugMode) {
39+
print(e);
40+
}
3841
}
3942
return super.onResponse(response, handler);
4043
}

lib/common/net/result_data.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/// Created by guoshuyu
33
/// Date: 2018-07-16
44
class ResultData {
5-
var data;
5+
dynamic data;
66
bool result;
77
int? code;
8-
var headers;
8+
dynamic headers;
99

1010
ResultData(this.data, this.result, this.code, {this.headers});
1111
}

lib/common/net/trending/github_trending.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class TrendingUtil {
4444
static htmlToRepo(String responseData) {
4545
try {
4646
responseData = responseData.replaceAll(RegExp('\n'), '');
47+
// ignore: empty_catches
4748
} catch (e) {}
4849
var repos = [];
4950
var splitWithH3 = responseData.split('<article');
@@ -112,7 +113,7 @@ class TrendingUtil {
112113
}
113114

114115
static parseRepoLabelWithTag(repo, noteContent, tag) {
115-
var startFlag;
116+
Object? startFlag;
116117
if (TAGS["starCount"] == tag || TAGS["forkCount"] == tag) {
117118
startFlag = tag["start"];
118119
} else {

0 commit comments

Comments
 (0)