Skip to content

Commit 053e757

Browse files
committed
fix pic swiper
1 parent 5f81da1 commit 053e757

File tree

5 files changed

+376
-366
lines changed

5 files changed

+376
-366
lines changed

lib/networking/http_request.dart

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
1-
import 'dart:io';
2-
3-
import 'package:http/http.dart' as http;
4-
5-
class NetworkException implements Exception {
6-
final message;
7-
8-
NetworkException([this.message]);
9-
10-
String toString() {
11-
if (message == null) return "Network Exception";
12-
return "Network Exception: $message";
13-
}
14-
}
15-
16-
class Request {
17-
static http.Client client = http.Client();
18-
19-
static Future<http.Response> httpGet(String url, Map<String, dynamic> body) async {
20-
if (body == null) {
21-
return await client.get(url);
22-
} else {
23-
var paramString = '?';
24-
body.forEach((k, v) {
25-
if (v != null) {
26-
paramString += k + '=' + v.toString() + '&';
27-
}
28-
});
29-
try {
30-
var result = await client.get(
31-
url + paramString.substring(0, paramString.length - 1),
32-
);
33-
return result;
34-
} catch (_) {
35-
throw NetworkException();
36-
}
37-
}
38-
}
39-
40-
static Future<http.Response> httpPost(String url, Map<String, dynamic> body) async {
41-
if (body == null) {
42-
try {
43-
var result = await client.post(url);
44-
return result;
45-
} catch (_) {
46-
throw NetworkException();
47-
}
48-
} else {
49-
Map<String, dynamic> paramMap = {};
50-
body.forEach((k, v) {
51-
if (v != null) {
52-
paramMap[k] = v.toString();
53-
}
54-
});
55-
try {
56-
var result = await client.post(url, body: paramMap);
57-
return result;
58-
} catch (_) {
59-
throw NetworkException();
60-
}
61-
}
62-
}
63-
64-
static Future<http.Response> httpUpload(String url, Map<String, dynamic> body, File file) async {
65-
try {
66-
var request = new http.MultipartRequest("POST", Uri.parse(url));
67-
if (body != null) {
68-
body.forEach((k, v) {
69-
if (v != null) {
70-
request.fields[k] = v.toString();
71-
}
72-
});
73-
}
74-
request.files.add(await http.MultipartFile.fromPath('file', file.path));
75-
var response = await request.send();
76-
return http.Response.fromStream(response);
77-
} catch (_) {
78-
throw NetworkException();
79-
}
80-
}
81-
}
1+
import 'dart:io';
2+
3+
import 'package:http/http.dart' as http;
4+
5+
class NetworkException implements Exception {
6+
final message;
7+
8+
NetworkException([this.message]);
9+
10+
String toString() {
11+
if (message == null) return "Network Exception";
12+
return "Network Exception: $message";
13+
}
14+
}
15+
16+
class Request {
17+
static http.Client client = http.Client();
18+
19+
static Future<http.Response> httpGet(String url, Map<String, dynamic> body) async {
20+
if (body == null) {
21+
return await client.get(Uri.parse(url));
22+
} else {
23+
var paramString = '?';
24+
body.forEach((k, v) {
25+
if (v != null) {
26+
paramString += k + '=' + v.toString() + '&';
27+
}
28+
});
29+
try {
30+
var result = await client.get(
31+
Uri.parse(url + paramString.substring(0, paramString.length - 1)),
32+
);
33+
return result;
34+
} catch (_) {
35+
throw NetworkException();
36+
}
37+
}
38+
}
39+
40+
static Future<http.Response> httpPost(String url, Map<String, dynamic> body) async {
41+
if (body == null) {
42+
try {
43+
var result = await client.post(Uri.parse(url));
44+
return result;
45+
} catch (_) {
46+
throw NetworkException();
47+
}
48+
} else {
49+
Map<String, dynamic> paramMap = {};
50+
body.forEach((k, v) {
51+
if (v != null) {
52+
paramMap[k] = v.toString();
53+
}
54+
});
55+
try {
56+
var result = await client.post(Uri.parse(url), body: paramMap);
57+
return result;
58+
} catch (_) {
59+
throw NetworkException();
60+
}
61+
}
62+
}
63+
64+
static Future<http.Response> httpUpload(String url, Map<String, dynamic> body, File file) async {
65+
try {
66+
var request = new http.MultipartRequest("POST", Uri.parse(url));
67+
if (body != null) {
68+
body.forEach((k, v) {
69+
if (v != null) {
70+
request.fields[k] = v.toString();
71+
}
72+
});
73+
}
74+
request.files.add(await http.MultipartFile.fromPath('file', file.path));
75+
var response = await request.send();
76+
return http.Response.fromStream(response);
77+
} catch (_) {
78+
throw NetworkException();
79+
}
80+
}
81+
}

lib/reusable_components/parsed_text.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ class ParsedText extends StatelessWidget {
9595
barrierDismissible: false,
9696
transitionDuration: Duration(milliseconds: 200),
9797
barrierLabel: "PicDialog",
98-
pageBuilder: (c, _, __) => PicSwiper(
99-
index: upId,
100-
pics: _pics,
101-
),
98+
pageBuilder: (c, _, __) {
99+
return PicSwiper(
100+
index: upId,
101+
pics: _pics,
102+
);
103+
},
102104
context: context,
103105
);
104106
},

0 commit comments

Comments
 (0)