Skip to content

Commit 930f952

Browse files
committed
migrate project to null safety
1 parent 3e83f8a commit 930f952

19 files changed

+305
-502
lines changed

lib/core/api.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ var url = locator<BaseUrl>();
1212

1313
class Api extends BaseApi {
1414
@override
15-
Future<FeaturedModel> featuredListApi() async {
16-
var response = await http.get(url.featuredUrl);
15+
Future<FeaturedModel?> featuredListApi() async {
16+
var response = await http.get(Uri.parse(url.featuredUrl));
1717

1818
var decode = json.decode(response.body);
1919
if (decode != null) {
@@ -25,8 +25,8 @@ class Api extends BaseApi {
2525
}
2626

2727
@override
28-
Future<CommunityModel> communityListApi() async {
29-
var response = await http.get(url.communityUrl);
28+
Future<CommunityModel?> communityListApi() async {
29+
var response = await http.get(Uri.parse(url.communityUrl));
3030

3131
var decode = json.decode(response.body);
3232
if (decode != null) {
@@ -38,8 +38,8 @@ class Api extends BaseApi {
3838
}
3939

4040
@override
41-
Future<BestModel> bestListApi() async {
42-
var response = await http.get(url.bestUrl);
41+
Future<BestModel?> bestListApi() async {
42+
var response = await http.get(Uri.parse(url.bestUrl));
4343

4444
var decode = json.decode(response.body);
4545
if (decode != null) {
@@ -51,8 +51,8 @@ class Api extends BaseApi {
5151
}
5252

5353
@override
54-
Future<NewModel> newListApi() async {
55-
var response = await http.get(url.newUrl);
54+
Future<NewModel?> newListApi() async {
55+
var response = await http.get(Uri.parse(url.newUrl));
5656

5757
var decode = json.decode(response.body);
5858
if (decode != null) {

lib/core/baseapi.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'models/bestmodel.dart';
44
import 'models/newmodel.dart';
55

66
abstract class BaseApi {
7-
Future<FeaturedModel> featuredListApi();
8-
Future<CommunityModel> communityListApi();
9-
Future<BestModel> bestListApi();
10-
Future<NewModel> newListApi();
7+
Future<FeaturedModel?> featuredListApi();
8+
Future<CommunityModel?> communityListApi();
9+
Future<BestModel?> bestListApi();
10+
Future<NewModel?> newListApi();
1111
}

lib/core/models/bestmodel.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class BestModel {
2-
Data data;
2+
Data? data;
33

44
BestModel({this.data});
55

@@ -10,14 +10,14 @@ class BestModel {
1010
Map<String, dynamic> toJson() {
1111
final Map<String, dynamic> data = new Map<String, dynamic>();
1212
if (this.data != null) {
13-
data['data'] = this.data.toJson();
13+
data['data'] = this.data!.toJson();
1414
}
1515
return data;
1616
}
1717
}
1818

1919
class Data {
20-
List<StoriesFeed> storiesFeed;
20+
List<StoriesFeed>? storiesFeed;
2121

2222
Data({this.storiesFeed});
2323

@@ -26,26 +26,26 @@ class Data {
2626
List<StoriesFeed> _storiesFeed = [];
2727
storiesFeed = _storiesFeed;
2828
json['storiesFeed'].forEach((v) {
29-
storiesFeed.add(new StoriesFeed.fromJson(v));
29+
storiesFeed!.add(new StoriesFeed.fromJson(v));
3030
});
3131
}
3232
}
3333

3434
Map<String, dynamic> toJson() {
3535
final Map<String, dynamic> data = new Map<String, dynamic>();
3636
if (this.storiesFeed != null) {
37-
data['storiesFeed'] = this.storiesFeed.map((v) => v.toJson()).toList();
37+
data['storiesFeed'] = this.storiesFeed!.map((v) => v.toJson()).toList();
3838
}
3939
return data;
4040
}
4141
}
4242

4343
class StoriesFeed {
44-
String title;
45-
Author author;
46-
String coverImage;
47-
String slug;
48-
int replyCount;
44+
String? title;
45+
Author? author;
46+
String? coverImage;
47+
String? slug;
48+
int? replyCount;
4949

5050
StoriesFeed(
5151
{this.title, this.author, this.coverImage, this.slug, this.replyCount});
@@ -63,7 +63,7 @@ class StoriesFeed {
6363
final Map<String, dynamic> data = new Map<String, dynamic>();
6464
data['title'] = this.title;
6565
if (this.author != null) {
66-
data['author'] = this.author.toJson();
66+
data['author'] = this.author!.toJson();
6767
}
6868
data['coverImage'] = this.coverImage;
6969
data['slug'] = this.slug;
@@ -73,9 +73,9 @@ class StoriesFeed {
7373
}
7474

7575
class Author {
76-
String name;
77-
String photo;
78-
String username;
76+
String? name;
77+
String? photo;
78+
String? username;
7979

8080
Author({this.name, this.photo, this.username});
8181

lib/core/models/communitymodel.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class CommunityModel {
2-
Data data;
2+
Data? data;
33

44
CommunityModel({this.data});
55

@@ -10,14 +10,14 @@ class CommunityModel {
1010
Map<String, dynamic> toJson() {
1111
final Map<String, dynamic> data = new Map<String, dynamic>();
1212
if (this.data != null) {
13-
data['data'] = this.data.toJson();
13+
data['data'] = this.data!.toJson();
1414
}
1515
return data;
1616
}
1717
}
1818

1919
class Data {
20-
List<StoriesFeed> storiesFeed;
20+
List<StoriesFeed>? storiesFeed;
2121

2222
Data({this.storiesFeed});
2323

@@ -26,26 +26,26 @@ class Data {
2626
List<StoriesFeed> _storiesFeed = [];
2727
storiesFeed = _storiesFeed;
2828
json['storiesFeed'].forEach((v) {
29-
storiesFeed.add(new StoriesFeed.fromJson(v));
29+
storiesFeed!.add(new StoriesFeed.fromJson(v));
3030
});
3131
}
3232
}
3333

3434
Map<String, dynamic> toJson() {
3535
final Map<String, dynamic> data = new Map<String, dynamic>();
3636
if (this.storiesFeed != null) {
37-
data['storiesFeed'] = this.storiesFeed.map((v) => v.toJson()).toList();
37+
data['storiesFeed'] = this.storiesFeed!.map((v) => v.toJson()).toList();
3838
}
3939
return data;
4040
}
4141
}
4242

4343
class StoriesFeed {
44-
String title;
45-
Author author;
46-
String coverImage;
47-
String slug;
48-
int replyCount;
44+
String? title;
45+
Author? author;
46+
String? coverImage;
47+
String? slug;
48+
int? replyCount;
4949

5050
StoriesFeed(
5151
{this.title, this.author, this.coverImage, this.slug, this.replyCount});
@@ -63,7 +63,7 @@ class StoriesFeed {
6363
final Map<String, dynamic> data = new Map<String, dynamic>();
6464
data['title'] = this.title;
6565
if (this.author != null) {
66-
data['author'] = this.author.toJson();
66+
data['author'] = this.author!.toJson();
6767
}
6868
data['coverImage'] = this.coverImage;
6969
data['slug'] = this.slug;
@@ -73,9 +73,9 @@ class StoriesFeed {
7373
}
7474

7575
class Author {
76-
String name;
77-
String photo;
78-
String username;
76+
String? name;
77+
String? photo;
78+
String? username;
7979

8080
Author({this.name, this.photo, this.username});
8181

lib/core/models/featuredmodel.dart

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class FeaturedModel {
2-
Data data;
2+
Data? data;
33

44
FeaturedModel({this.data});
55

@@ -10,14 +10,14 @@ class FeaturedModel {
1010
Map<String, dynamic> toJson() {
1111
final Map<String, dynamic> data = new Map<String, dynamic>();
1212
if (this.data != null) {
13-
data['data'] = this.data.toJson();
13+
data['data'] = this.data!.toJson();
1414
}
1515
return data;
1616
}
1717
}
1818

1919
class Data {
20-
List<StoriesFeed> storiesFeed;
20+
List<StoriesFeed>? storiesFeed;
2121

2222
Data({this.storiesFeed});
2323

@@ -26,64 +26,56 @@ class Data {
2626
List<StoriesFeed> _storiesFeed = [];
2727
storiesFeed = _storiesFeed;
2828
json['storiesFeed'].forEach((v) {
29-
storiesFeed.add(new StoriesFeed.fromJson(v));
29+
storiesFeed!.add(new StoriesFeed.fromJson(v));
3030
});
3131
}
3232
}
3333

3434
Map<String, dynamic> toJson() {
3535
final Map<String, dynamic> data = new Map<String, dynamic>();
3636
if (this.storiesFeed != null) {
37-
data['storiesFeed'] = this.storiesFeed.map((v) => v.toJson()).toList();
37+
data['storiesFeed'] = this.storiesFeed!.map((v) => v.toJson()).toList();
3838
}
3939
return data;
4040
}
4141
}
4242

4343
class StoriesFeed {
44-
String title;
45-
Author author;
46-
String coverImage;
47-
String slug;
48-
String dateFeatured;
49-
int replyCount;
44+
String? title;
45+
Author? author;
46+
String? coverImage;
47+
String? slug;
48+
int? replyCount;
5049

5150
StoriesFeed(
52-
{this.title,
53-
this.author,
54-
this.coverImage,
55-
this.slug,
56-
this.dateFeatured,
57-
this.replyCount});
51+
{this.title, this.author, this.coverImage, this.slug, this.replyCount});
5852

5953
StoriesFeed.fromJson(Map<String, dynamic> json) {
6054
title = json['title'];
6155
author =
6256
json['author'] != null ? new Author.fromJson(json['author']) : null;
6357
coverImage = json['coverImage'];
6458
slug = json['slug'];
65-
dateFeatured = json['dateFeatured'];
6659
replyCount = json['replyCount'];
6760
}
6861

6962
Map<String, dynamic> toJson() {
7063
final Map<String, dynamic> data = new Map<String, dynamic>();
7164
data['title'] = this.title;
7265
if (this.author != null) {
73-
data['author'] = this.author.toJson();
66+
data['author'] = this.author!.toJson();
7467
}
7568
data['coverImage'] = this.coverImage;
7669
data['slug'] = this.slug;
77-
data['dateFeatured'] = this.dateFeatured;
7870
data['replyCount'] = this.replyCount;
7971
return data;
8072
}
8173
}
8274

8375
class Author {
84-
String name;
85-
String photo;
86-
String username;
76+
String? name;
77+
String? photo;
78+
String? username;
8779

8880
Author({this.name, this.photo, this.username});
8981

lib/core/models/newmodel.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class NewModel {
2-
Data data;
2+
Data? data;
33

44
NewModel({this.data});
55

@@ -10,14 +10,14 @@ class NewModel {
1010
Map<String, dynamic> toJson() {
1111
final Map<String, dynamic> data = new Map<String, dynamic>();
1212
if (this.data != null) {
13-
data['data'] = this.data.toJson();
13+
data['data'] = this.data!.toJson();
1414
}
1515
return data;
1616
}
1717
}
1818

1919
class Data {
20-
List<StoriesFeed> storiesFeed;
20+
List<StoriesFeed>? storiesFeed;
2121

2222
Data({this.storiesFeed});
2323

@@ -26,26 +26,26 @@ class Data {
2626
List<StoriesFeed> _storiesFeed = [];
2727
storiesFeed = _storiesFeed;
2828
json['storiesFeed'].forEach((v) {
29-
storiesFeed.add(new StoriesFeed.fromJson(v));
29+
storiesFeed!.add(new StoriesFeed.fromJson(v));
3030
});
3131
}
3232
}
3333

3434
Map<String, dynamic> toJson() {
3535
final Map<String, dynamic> data = new Map<String, dynamic>();
3636
if (this.storiesFeed != null) {
37-
data['storiesFeed'] = this.storiesFeed.map((v) => v.toJson()).toList();
37+
data['storiesFeed'] = this.storiesFeed!.map((v) => v.toJson()).toList();
3838
}
3939
return data;
4040
}
4141
}
4242

4343
class StoriesFeed {
44-
String title;
45-
Author author;
46-
String coverImage;
47-
String slug;
48-
int replyCount;
44+
String? title;
45+
Author? author;
46+
String? coverImage;
47+
String? slug;
48+
int? replyCount;
4949

5050
StoriesFeed(
5151
{this.title, this.author, this.coverImage, this.slug, this.replyCount});
@@ -63,7 +63,7 @@ class StoriesFeed {
6363
final Map<String, dynamic> data = new Map<String, dynamic>();
6464
data['title'] = this.title;
6565
if (this.author != null) {
66-
data['author'] = this.author.toJson();
66+
data['author'] = this.author!.toJson();
6767
}
6868
data['coverImage'] = this.coverImage;
6969
data['slug'] = this.slug;
@@ -73,9 +73,9 @@ class StoriesFeed {
7373
}
7474

7575
class Author {
76-
String name;
77-
String photo;
78-
String username;
76+
String? name;
77+
String? photo;
78+
String? username;
7979

8080
Author({this.name, this.photo, this.username});
8181

0 commit comments

Comments
 (0)