Skip to content

Commit fe7d19b

Browse files
committed
⬆️ Upgrade firebase packages
1 parent e98a67e commit fe7d19b

29 files changed

+328
-284
lines changed

lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:firebase_database/firebase_database.dart';
2+
import 'package:firebase_core/firebase_core.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter_twitter_clone/helper/theme.dart';
45
import 'package:flutter_twitter_clone/state/searchState.dart';
@@ -12,13 +13,13 @@ import 'package:google_fonts/google_fonts.dart';
1213

1314
import 'state/notificationState.dart';
1415

15-
void main() {
16+
void main() async {
1617
WidgetsFlutterBinding.ensureInitialized();
18+
await Firebase.initializeApp();
1719
runApp(MyApp());
1820
}
1921

2022
class MyApp extends StatelessWidget {
21-
2223
@override
2324
Widget build(BuildContext context) {
2425
return MultiProvider(
@@ -28,7 +29,8 @@ class MyApp extends StatelessWidget {
2829
ChangeNotifierProvider<FeedState>(create: (_) => FeedState()),
2930
ChangeNotifierProvider<ChatState>(create: (_) => ChatState()),
3031
ChangeNotifierProvider<SearchState>(create: (_) => SearchState()),
31-
ChangeNotifierProvider<NotificationState>(create: (_) => NotificationState()),
32+
ChangeNotifierProvider<NotificationState>(
33+
create: (_) => NotificationState()),
3234
],
3335
child: MaterialApp(
3436
title: 'Fwitter',

lib/model/feedModel.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FeedModel {
1414
String imagePath;
1515
List<String> tags;
1616
List<String> replyTweetKeyList;
17-
User user;
17+
UserModel user;
1818
FeedModel(
1919
{this.key,
2020
this.description,
@@ -61,7 +61,7 @@ class FeedModel {
6161
createdAt = map['createdAt'];
6262
imagePath = map['imagePath'];
6363
// username = map['username'];
64-
user = User.fromJson(map['user']);
64+
user = UserModel.fromJson(map['user']);
6565
parentkey = map['parentkey'];
6666
childRetwetkey = map['childRetwetkey'];
6767
if (map['tags'] != null) {
@@ -74,22 +74,24 @@ class FeedModel {
7474
likeList = List<String>();
7575

7676
final list = map['likeList'];
77+
7778
/// In new tweet db schema likeList is stored as a List<String>()
78-
///
79+
///
7980
if (list is List) {
8081
map['likeList'].forEach((value) {
8182
if (value is String) {
8283
likeList.add(value);
83-
}
84+
}
8485
});
8586
likeCount = likeList.length ?? 0;
8687
}
88+
8789
/// In old database tweet db schema likeList is saved in the form of map
8890
/// like list map is removed from latest code but to support old schema below code is required
8991
/// Once all user migrated to new version like list map support will be removed
90-
else if(list is Map){
92+
else if (list is Map) {
9193
list.forEach((key, value) {
92-
likeList.add(value["userId"]);
94+
likeList.add(value["userId"]);
9395
});
9496
likeCount = list.length;
9597
}

lib/model/user.dart

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class User {
1+
class UserModel {
22
String key;
33
String email;
44
String userId;
@@ -18,31 +18,31 @@ class User {
1818
List<String> followersList;
1919
List<String> followingList;
2020

21-
User(
22-
{this.email,
23-
this.userId,
24-
this.displayName,
25-
this.profilePic,
26-
this.key,
27-
this.contact,
28-
this.bio,
29-
this.dob,
30-
this.location,
31-
this.createdAt,
32-
this.userName,
33-
this.followers,
34-
this.following,
35-
this.webSite,
36-
this.isVerified,
37-
this.fcmToken,
38-
this.followersList,
39-
});
21+
UserModel({
22+
this.email,
23+
this.userId,
24+
this.displayName,
25+
this.profilePic,
26+
this.key,
27+
this.contact,
28+
this.bio,
29+
this.dob,
30+
this.location,
31+
this.createdAt,
32+
this.userName,
33+
this.followers,
34+
this.following,
35+
this.webSite,
36+
this.isVerified,
37+
this.fcmToken,
38+
this.followersList,
39+
});
4040

41-
User.fromJson(Map<dynamic, dynamic> map) {
41+
UserModel.fromJson(Map<dynamic, dynamic> map) {
4242
if (map == null) {
4343
return;
4444
}
45-
if(followersList == null){
45+
if (followersList == null) {
4646
followersList = [];
4747
}
4848
email = map['email'];
@@ -61,20 +61,20 @@ class User {
6161
webSite = map['webSite'];
6262
fcmToken = map['fcmToken'];
6363
isVerified = map['isVerified'] ?? false;
64-
if(map['followerList'] != null){
64+
if (map['followerList'] != null) {
6565
followersList = List<String>();
66-
map['followerList'].forEach((value){
67-
followersList.add(value);
68-
});
69-
}
70-
followers = followersList != null ? followersList.length : null;
71-
if(map['followingList'] != null){
66+
map['followerList'].forEach((value) {
67+
followersList.add(value);
68+
});
69+
}
70+
followers = followersList != null ? followersList.length : null;
71+
if (map['followingList'] != null) {
7272
followingList = List<String>();
73-
map['followingList'].forEach((value){
74-
followingList.add(value);
75-
});
76-
}
77-
following = followingList != null ? followingList.length : null;
73+
map['followingList'].forEach((value) {
74+
followingList.add(value);
75+
});
76+
}
77+
following = followingList != null ? followingList.length : null;
7878
}
7979
toJson() {
8080
return {
@@ -90,54 +90,54 @@ class User {
9090
'location': location,
9191
'createdAt': createdAt,
9292
'followers': followersList != null ? followersList.length : null,
93-
'following': followingList!= null ? followingList.length : null,
93+
'following': followingList != null ? followingList.length : null,
9494
'userName': userName,
9595
'webSite': webSite,
9696
'isVerified': isVerified ?? false,
97-
'fcmToken':fcmToken,
98-
'followerList' : followersList,
99-
'followingList':followingList
97+
'fcmToken': fcmToken,
98+
'followerList': followersList,
99+
'followingList': followingList
100100
};
101101
}
102102

103-
User copyWith(
104-
{String email,
105-
String userId,
106-
String displayName,
107-
String profilePic,
108-
String key,
109-
String contact,
110-
bio,
111-
String dob,
112-
String location,
113-
String createdAt,
114-
String userName,
115-
int followers,
116-
int following,
117-
String webSite,
118-
bool isVerified,
119-
String fcmToken,
120-
List<String> followingList,
121-
}) {
122-
return User(
123-
email: email ?? this.email,
124-
bio: bio ?? this.bio,
125-
contact: contact ?? this.contact,
126-
createdAt: createdAt ?? this.createdAt,
127-
displayName: displayName ?? this.displayName,
128-
dob: dob ?? this.dob,
129-
followers: followersList != null ? followersList.length : null,
130-
following: following ?? this.following,
131-
isVerified: isVerified ?? this.isVerified,
132-
key: key ?? this.key,
133-
location: location ?? this.location,
134-
profilePic: profilePic ?? this.profilePic,
135-
userId: userId ?? this.userId,
136-
userName: userName ?? this.userName,
137-
webSite: webSite ?? this.webSite,
138-
fcmToken:fcmToken ?? this.fcmToken,
139-
followersList: followersList ?? this.followersList,
140-
);
103+
UserModel copyWith({
104+
String email,
105+
String userId,
106+
String displayName,
107+
String profilePic,
108+
String key,
109+
String contact,
110+
bio,
111+
String dob,
112+
String location,
113+
String createdAt,
114+
String userName,
115+
int followers,
116+
int following,
117+
String webSite,
118+
bool isVerified,
119+
String fcmToken,
120+
List<String> followingList,
121+
}) {
122+
return UserModel(
123+
email: email ?? this.email,
124+
bio: bio ?? this.bio,
125+
contact: contact ?? this.contact,
126+
createdAt: createdAt ?? this.createdAt,
127+
displayName: displayName ?? this.displayName,
128+
dob: dob ?? this.dob,
129+
followers: followersList != null ? followersList.length : null,
130+
following: following ?? this.following,
131+
isVerified: isVerified ?? this.isVerified,
132+
key: key ?? this.key,
133+
location: location ?? this.location,
134+
profilePic: profilePic ?? this.profilePic,
135+
userId: userId ?? this.userId,
136+
userName: userName ?? this.userName,
137+
webSite: webSite ?? this.webSite,
138+
fcmToken: fcmToken ?? this.fcmToken,
139+
followersList: followersList ?? this.followersList,
140+
);
141141
}
142142

143143
String getFollower() {

lib/page/Auth/signup.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class _SignupState extends State<Signup> {
173173
Random random = new Random();
174174
int randomNumber = random.nextInt(8);
175175

176-
User user = User(
176+
UserModel user = UserModel(
177177
email: _emailController.text.toLowerCase(),
178178
bio: 'Edit profile to update bio',
179179
// contact: _mobileController.text,

lib/page/Auth/verifyEmail.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _VerifyEmailPageState extends State<VerifyEmailPage> {
2525
child: Column(
2626
mainAxisAlignment: MainAxisAlignment.center,
2727
crossAxisAlignment: CrossAxisAlignment.center,
28-
children: state.user.isEmailVerified
28+
children: state.user.emailVerified
2929
? <Widget>[
3030
NotifyText(
3131
title: 'Your email address is verified',
@@ -75,7 +75,6 @@ class _VerifyEmailPageState extends State<VerifyEmailPage> {
7575
void _submit() {
7676
var state = Provider.of<AuthState>(context, listen: false);
7777
state.sendEmailVerification(_scaffoldKey);
78-
7978
}
8079

8180
@override

lib/page/common/usersListPage.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class UsersListPage extends StatelessWidget {
2727

2828
@override
2929
Widget build(BuildContext context) {
30-
List<User> userList;
30+
List<UserModel> userList;
3131
return Scaffold(
3232
backgroundColor: TwitterColor.mystic,
3333
appBar: CustomAppBar(

lib/page/common/widget/userListWidget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:flutter_twitter_clone/widgets/newWidget/title_text.dart';
1010
import 'package:provider/provider.dart';
1111

1212
class UserListWidget extends StatelessWidget {
13-
final List<User> list;
13+
final List<UserModel> list;
1414
final String emptyScreenText;
1515
final String emptyScreenSubTileText;
1616
UserListWidget({
@@ -44,7 +44,7 @@ class UserListWidget extends StatelessWidget {
4444

4545
class UserTile extends StatelessWidget {
4646
const UserTile({Key key, this.user, this.myId}) : super(key: key);
47-
final User user;
47+
final UserModel user;
4848
final String myId;
4949

5050
/// Return empty string for default bio

0 commit comments

Comments
 (0)