Skip to content

Commit

Permalink
refactor: updated lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Nov 10, 2023
1 parent 7449ffd commit d1c97b6
Show file tree
Hide file tree
Showing 35 changed files with 810 additions and 2,215 deletions.
28 changes: 10 additions & 18 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
#include: package:lint/analysis_options.yaml

analyzer:
strong-mode:
implicit-dynamic: false
exclude:
- "**/*.chopper.dart"
include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
close_sinks: true
public_member_api_docs: false
flutter_style_todos: false
avoid_final_parameters: false
sort_constructors_first: false
avoid_classes_with_only_static_members: false
avoid_void_async: false
avoid_positional_boolean_parameters: false
avoid_function_literals_in_foreach_calls: false
avoid_positional_boolean_parameters: false
use_if_null_to_convert_nulls_to_bools: false
use_build_context_synchronously: false
prefer_constructors_over_static_methods: false
sort_unnamed_constructors_first: false
sized_box_for_whitespace: false
invalid_dependency: false
sort_pub_dependencies: false
directives_ordering: false
noop_primitive_operations: false
use_build_context_synchronously: false
use_setters_to_change_properties: false
avoid_print: false
sort_pub_dependencies: false
118 changes: 59 additions & 59 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,38 +70,38 @@ class _MyAppState extends State<MyApp> {
children: [
const SizedBox(height: 8),
_getTextWidget(
"Welcome to example of Alice Http Inspector. Click buttons below to generate sample data."),
'Welcome to example of Alice Http Inspector. Click buttons below to generate sample data.'),
ElevatedButton(
child: Text("Run Dio HTTP Requests"),
child: Text('Run Dio HTTP Requests'),
onPressed: _runDioRequests,
style: _buttonStyle,
),
ElevatedButton(
child: Text("Run http/http HTTP Requests"),
child: Text('Run http/http HTTP Requests'),
onPressed: _runHttpHttpRequests,
style: _buttonStyle,
),
ElevatedButton(
child: Text("Run HttpClient Requests"),
child: Text('Run HttpClient Requests'),
onPressed: _runHttpHttpClientRequests,
style: _buttonStyle,
),
ElevatedButton(
child: Text("Run Chopper HTTP Requests"),
child: Text('Run Chopper HTTP Requests'),
onPressed: _runChopperHttpRequests,
style: _buttonStyle,
),
ElevatedButton(
child: Text("Log example data"),
child: Text('Log example data'),
onPressed: _logExampleData,
style: _buttonStyle,
),
const SizedBox(height: 24),
_getTextWidget(
"After clicking on buttons above, you should receive notification."
" Click on it to show inspector. You can also shake your device or click button below."),
'After clicking on buttons above, you should receive notification.'
' Click on it to show inspector. You can also shake your device or click button below.'),
ElevatedButton(
child: Text("Run HTTP Inspector"),
child: Text('Run HTTP Inspector'),
onPressed: _runHttpInspector,
style: _buttonStyle,
)
Expand Down Expand Up @@ -162,70 +162,70 @@ class _MyAppState extends State<MyApp> {

void _runChopperHttpRequests() async {
String body = jsonEncode(
<String, dynamic>{"title": "foo", "body": "bar", "userId": "1"});
_postsService.getPost("1");
<String, dynamic>{'title': 'foo', 'body': 'bar', 'userId': '1'});
_postsService.getPost('1');
_postsService.postPost(body);
_postsService.putPost("1", body);
_postsService.putPost("1231923", body);
_postsService.putPost("1", null);
_postsService.putPost('1', body);
_postsService.putPost('1231923', body);
_postsService.putPost('1', null);
_postsService.postPost(null);
_postsService.getPost("123456");
_postsService.getPost('123456');
}

void _runDioRequests() async {
Map<String, dynamic> body = <String, dynamic>{
"title": "foo",
"body": "bar",
"userId": "1"
'title': 'foo',
'body': 'bar',
'userId': '1'
};
_dio.get<void>(
"https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org");
_dio.delete<void>("https://httpbin.org/status/500");
_dio.delete<void>("https://httpbin.org/status/400");
_dio.delete<void>("https://httpbin.org/status/300");
_dio.delete<void>("https://httpbin.org/status/200");
_dio.delete<void>("https://httpbin.org/status/100");
_dio.post<void>("https://jsonplaceholder.typicode.com/posts", data: body);
_dio.get<void>("https://jsonplaceholder.typicode.com/posts",
queryParameters: <String, dynamic>{"test": 1});
_dio.put<void>("https://jsonplaceholder.typicode.com/posts/1", data: body);
_dio.put<void>("https://jsonplaceholder.typicode.com/posts/1", data: body);
_dio.delete<void>("https://jsonplaceholder.typicode.com/posts/1");
_dio.get<void>("http://jsonplaceholder.typicode.com/test/test");

_dio.get<void>("https://jsonplaceholder.typicode.com/photos");
'https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org');
_dio.delete<void>('https://httpbin.org/status/500');
_dio.delete<void>('https://httpbin.org/status/400');
_dio.delete<void>('https://httpbin.org/status/300');
_dio.delete<void>('https://httpbin.org/status/200');
_dio.delete<void>('https://httpbin.org/status/100');
_dio.post<void>('https://jsonplaceholder.typicode.com/posts', data: body);
_dio.get<void>('https://jsonplaceholder.typicode.com/posts',
queryParameters: <String, dynamic>{'test': 1});
_dio.put<void>('https://jsonplaceholder.typicode.com/posts/1', data: body);
_dio.put<void>('https://jsonplaceholder.typicode.com/posts/1', data: body);
_dio.delete<void>('https://jsonplaceholder.typicode.com/posts/1');
_dio.get<void>('http://jsonplaceholder.typicode.com/test/test');

_dio.get<void>('https://jsonplaceholder.typicode.com/photos');
_dio.get<void>(
"https://icons.iconarchive.com/icons/paomedia/small-n-flat/256/sign-info-icon.png");
'https://icons.iconarchive.com/icons/paomedia/small-n-flat/256/sign-info-icon.png');
_dio.get<void>(
"https://images.unsplash.com/photo-1542736705-53f0131d1e98?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80");
'https://images.unsplash.com/photo-1542736705-53f0131d1e98?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80');
_dio.get<void>(
"https://findicons.com/files/icons/1322/world_of_aqua_5/128/bluetooth.png");
'https://findicons.com/files/icons/1322/world_of_aqua_5/128/bluetooth.png');
_dio.get<void>(
"https://upload.wikimedia.org/wikipedia/commons/4/4e/Pleiades_large.jpg");
_dio.get<void>("http://techslides.com/demos/sample-videos/small.mp4");
'https://upload.wikimedia.org/wikipedia/commons/4/4e/Pleiades_large.jpg');
_dio.get<void>('http://techslides.com/demos/sample-videos/small.mp4');

_dio.get<void>("https://www.cse.wustl.edu/~jain/cis677-97/ftp/e_3dlc2.pdf");
_dio.get<void>('https://www.cse.wustl.edu/~jain/cis677-97/ftp/e_3dlc2.pdf');

final directory = await getApplicationDocumentsDirectory();
File file = File("${directory.path}/test.txt");
File file = File('${directory.path}/test.txt');
file.create();
file.writeAsStringSync("123456789");
file.writeAsStringSync('123456789');

String fileName = file.path.split('/').last;
FormData formData = FormData.fromMap(<String, dynamic>{
"file": await MultipartFile.fromFile(file.path, filename: fileName),
'file': await MultipartFile.fromFile(file.path, filename: fileName),
});
_dio.post<void>("https://jsonplaceholder.typicode.com/photos",
_dio.post<void>('https://jsonplaceholder.typicode.com/photos',
data: formData);

_dio.get<void>("http://dummy.restapiexample.com/api/v1/employees");
_dio.get<void>('http://dummy.restapiexample.com/api/v1/employees');
}

void _runHttpHttpRequests() async {
Map<String, String> body = <String, String>{
"title": "foo",
"body": "bar",
"userId": "1"
'title': 'foo',
'body': 'bar',
'userId': '1'
};
http
.post(Uri.tryParse('https://jsonplaceholder.typicode.com/posts')!,
Expand Down Expand Up @@ -317,28 +317,28 @@ class _MyAppState extends State<MyApp> {

void _runHttpHttpClientRequests() {
Map<String, dynamic> body = <String, dynamic>{
"title": "foo",
"body": "bar",
"userId": "1"
'title': 'foo',
'body': 'bar',
'userId': '1'
};
_httpClient
.getUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
.getUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts'))
.interceptWithAlice(_alice);

_httpClient
.postUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
.postUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts'))
.interceptWithAlice(_alice, body: body, headers: <String, dynamic>{});

_httpClient
.putUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts/1"))
.putUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'))
.interceptWithAlice(_alice, body: body);

_httpClient
.getUrl(Uri.parse("https://jsonplaceholder.typicode.com/test/test/"))
.getUrl(Uri.parse('https://jsonplaceholder.typicode.com/test/test/'))
.interceptWithAlice(_alice);

_httpClient
.postUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
.postUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts'))
.then((request) async {
_alice.onHttpClientRequest(request, body: body);
request.write(body);
Expand All @@ -348,7 +348,7 @@ class _MyAppState extends State<MyApp> {
});

_httpClient
.putUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts/1"))
.putUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'))
.then((request) async {
_alice.onHttpClientRequest(request, body: body);
request.write(body);
Expand All @@ -358,7 +358,7 @@ class _MyAppState extends State<MyApp> {
});

_httpClient
.patchUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts/1"))
.patchUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'))
.then((request) async {
_alice.onHttpClientRequest(request, body: body);
request.write(body);
Expand All @@ -368,7 +368,7 @@ class _MyAppState extends State<MyApp> {
});

_httpClient
.deleteUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts/1"))
.deleteUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'))
.then((request) async {
_alice.onHttpClientRequest(request);
var httpResponse = await request.close();
Expand All @@ -377,7 +377,7 @@ class _MyAppState extends State<MyApp> {
});

_httpClient
.getUrl(Uri.parse("https://jsonplaceholder.typicode.com/test/test/"))
.getUrl(Uri.parse('https://jsonplaceholder.typicode.com/test/test/'))
.then((request) async {
_alice.onHttpClientRequest(request);
var httpResponse = await request.close();
Expand Down
5 changes: 3 additions & 2 deletions example/lib/posts_service.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import "dart:async";

import 'package:chopper/chopper.dart';

// this is necessary for the generated code to find your class
part "posts_service.chopper.dart";
part 'posts_service.chopper.dart';

@ChopperApi(baseUrl: "https://jsonplaceholder.typicode.com/posts")
@ChopperApi(baseUrl: 'https://jsonplaceholder.typicode.com/posts')
abstract class PostsService extends ChopperService {
// helper methods that help you instantiate your service
static PostsService create([ChopperClient? client]) =>
Expand Down
Loading

0 comments on commit d1c97b6

Please sign in to comment.