Skip to content

Commit

Permalink
fix: fix #630 Null check operator used on a null value
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorwang committed Oct 23, 2023
1 parent dffdf03 commit a53b4f0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
38 changes: 38 additions & 0 deletions example/lib/auth_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:dio/dio.dart';
import 'package:retrofit/retrofit.dart';

part 'auth_client.g.dart';

@RestApi()
abstract class AuthClient {
factory AuthClient(Dio dio, {String? baseUrl}) = RestClientYmlp;

@POST('/api/auth/mqttClient/authentication')
Future<Object?> authenticationUsingPost({
@Body() required RegisterModel submitModel,
});
}

class RegisterModel {
const RegisterModel({
this.channel,
this.mobile,
this.verfiyCode,
});

factory RegisterModel.fromJson(Map<String, Object?> json) => RegisterModel(
channel: json['channel'] as String?,
mobile: json['mobile'] as String?,
verfiyCode: json['verfiyCode'] as String?,
);

final String? channel;
final String? mobile;
final String? verfiyCode;

Map<String, dynamic> toJson() => <String, dynamic>{
'channel': channel,
'mobile': mobile,
'verfiyCode': verfiyCode,
};
}
6 changes: 6 additions & 0 deletions generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 8.0.2

- fix #630 Null check operator used on a null value

## 8.0.1

- Add option class-name to customize the name of retrofit generator
Expand All @@ -10,6 +14,7 @@
- Add PreventNullToAbsent annotation to allow null sent to server

## 7.0.8

- Use `toJson()` instead of `.name` if enums have `toJson()`.

## 7.0.7
Expand All @@ -20,6 +25,7 @@
## 7.0.6

- Fix DateTime.toIso8601String() issue #586

## 7.0.3

- Add support for analyzer 6.0.0
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ You should create a new class to encapsulate the response.
)
.statement,
);
} else if (returnType.toString() == 'dynamic') {
} else if (returnType is DynamicType || returnType.isDartCoreObject) {
blocks
..add(
declareFinal(_resultVar)
Expand Down

0 comments on commit a53b4f0

Please sign in to comment.