Skip to content

Commit

Permalink
Make objects const
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Amador committed Nov 8, 2023
1 parent e1cfd59 commit 0c95f3b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
37 changes: 22 additions & 15 deletions lib/src/common/model/changes.dart
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

part 'changes.g.dart';

@immutable
@JsonSerializable()
class Ref {
Ref(this.from);
String? from;
const Ref(this.from);
final String? from;

factory Ref.fromJson(Map<String, dynamic> input) => _$RefFromJson(input);
Map<String, dynamic> toJson() => _$RefToJson(this);
}

@immutable
@JsonSerializable()
class Sha {
Sha(this.from);
String? from;
const Sha(this.from);
final String? from;

factory Sha.fromJson(Map<String, dynamic> input) => _$ShaFromJson(input);
Map<String, dynamic> toJson() => _$ShaToJson(this);
}

@immutable
@JsonSerializable()
class Base {
Base(this.ref, this.sha);
Ref? ref;
Sha? sha;
const Base(this.ref, this.sha);
final Ref? ref;
final Sha? sha;

factory Base.fromJson(Map<String, dynamic> input) => _$BaseFromJson(input);
Map<String, dynamic> toJson() => _$BaseToJson(this);
}

@immutable
@JsonSerializable()
class Body {
Body(this.from);
String? from;
const Body(this.from);
final String? from;

factory Body.fromJson(Map<String, dynamic> input) => _$BodyFromJson(input);
Map<String, dynamic> toJson() => _$BodyToJson(this);
}

@immutable
@JsonSerializable()
class Title {
Title({this.from});
String? from;
const Title({this.from});
final String? from;

factory Title.fromJson(Map<String, dynamic> input) => _$TitleFromJson(input);
Map<String, dynamic> toJson() => _$TitleToJson(this);
}

@immutable
@JsonSerializable()
class Changes {
Changes(this.base, this.body, this.title);
Base? base;
Body? body;
Title? title;
const Changes(this.base, this.body, this.title);
final Base? base;
final Body? body;
final Title? title;

factory Changes.fromJson(Map<String, dynamic> input) =>
_$ChangesFromJson(input);
Expand Down
4 changes: 3 additions & 1 deletion lib/src/server/hooks.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:github/src/common/model/changes.dart';

import 'package:json_annotation/json_annotation.dart';

import '../common.dart';
import '../common/model/changes.dart';

part 'hooks.g.dart';

Expand Down

0 comments on commit 0c95f3b

Please sign in to comment.