Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/null safety migration #212

Merged
merged 23 commits into from Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified chopper/.DS_Store
Binary file not shown.
5 changes: 2 additions & 3 deletions chopper/README.md
Expand Up @@ -11,7 +11,7 @@ Chopper is an http client generator for Dart and Flutter using source_gen and in
In your project's `pubspec.yaml` file,

* Add *chopper*'s latest version to your *dependencies*.
* Add `build_runner: ^1.10.3` to your *dev_dependencies*.
* Add `build_runner: ^1.12.2` to your *dev_dependencies*.
* *build_runner* may already be in your *dev_dependencies* depending on your project setup and other dependencies.
* Add *chopper_generator*'s latest version to your *dev_dependencies*.

Expand All @@ -22,7 +22,7 @@ dependencies:
chopper: ^<latest version>

dev_dependencies:
build_runner: ^1.10.3
build_runner: ^1.12.2
chopper_generator: ^<latest version>
```

Expand All @@ -44,4 +44,3 @@ Latest versions:
* [Angular](https://github.com/lejard-h/chopper/blob/master/example/web/main.dart)

## If you encounter any issues, or need a feature implemented, please visit [Chopper's Issue Tracker on GitHub](https://github.com/lejard-h/chopper/issues).

2 changes: 1 addition & 1 deletion chopper/example/definition.chopper.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chopper/example/definition.dart
Expand Up @@ -5,7 +5,7 @@ part 'definition.chopper.dart';

@ChopperApi(baseUrl: '/resources')
abstract class MyService extends ChopperService {
static MyService create([ChopperClient client]) => _$MyService(client);
static MyService create(ChopperClient client) => _$MyService(client);

@Get(path: '/{id}')
Future<Response> getResource(
Expand Down
2 changes: 1 addition & 1 deletion chopper/example/main.dart
Expand Up @@ -7,7 +7,7 @@ Future<void> main() async {
baseUrl: 'http://localhost:8000',
services: [
// the generated service
MyService.create()
MyService.create(ChopperClient())
],
converter: JsonConverter(),
);
Expand Down
21 changes: 11 additions & 10 deletions chopper/lib/src/annotations.dart
Expand Up @@ -48,7 +48,7 @@ class Path {
/// @Get(path: '/{param}')
/// Future<Response> fetch(@Path('param') String hello);
/// ```
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved

const Path([this.name]);
}
Expand All @@ -71,7 +71,7 @@ class Query {
/// @Get(path: '/something')
/// Future<Response> fetch({@Query('id') String mySuperId});
/// ```
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved
lejard-h marked this conversation as resolved.
Show resolved Hide resolved

const Query([this.name]);
}
Expand Down Expand Up @@ -123,7 +123,7 @@ class Header {
/// @Get()
/// Future<Response> fetch(@Header('foo') String headerFoo);
/// ```
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved

const Header([this.name]);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ class Method {

const Method(
this.method, {
this.optionalBody,
this.optionalBody = false,
this.path = '',
this.headers = const {},
});
Expand Down Expand Up @@ -264,6 +264,7 @@ class Head extends Method {

/// A function that should convert the body of a [Request] to the HTTP representation.
typedef ConvertRequest = FutureOr<Request> Function(Request request);

/// A function that should convert the body of a [Response] from the HTTP
/// representation to a Dart object.
typedef ConvertResponse<T> = FutureOr<Response> Function(Response response);
Expand Down Expand Up @@ -298,8 +299,8 @@ typedef ConvertResponse<T> = FutureOr<Response> Function(Response response);
/// }
@immutable
class FactoryConverter {
final ConvertRequest request;
final ConvertResponse response;
final ConvertRequest? request;
final ConvertResponse? response;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved

const FactoryConverter({
this.request,
Expand All @@ -322,7 +323,7 @@ class Field {
/// @Post(path: '/')
/// Future<Response> create(@Field('id') String myId);
/// ```
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved

const Field([this.name]);
}
Expand All @@ -349,7 +350,7 @@ class Multipart {
/// Also accepts `MultipartFile` (from package:http).
@immutable
class Part {
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved
const Part([this.name]);
}

Expand All @@ -367,7 +368,7 @@ class Part {
/// - `MultipartFile` (from package:http)
@immutable
class PartFile {
final String name;
final String? name;
stewemetal marked this conversation as resolved.
Show resolved Hide resolved

const PartFile([this.name]);
}
Expand All @@ -387,7 +388,7 @@ class PartFile {
@immutable
@Deprecated('Use PartFile instead')
class FileField extends PartFile {
const FileField([String name]) : super(name);
const FileField([String? name]) : super(name);
stewemetal marked this conversation as resolved.
Show resolved Hide resolved
lejard-h marked this conversation as resolved.
Show resolved Hide resolved
}

const multipart = Multipart();
Expand Down