Skip to content

Commit 31093ec

Browse files
committed
📈 Make compatible with flutter v3.0.1.
⬆️ Upgrade some packages. ✏️ Fix typos.
1 parent 775b2ec commit 31093ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+533
-477
lines changed

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"cSpell.words": [
3+
"Alives",
4+
"Fwitter",
5+
"parentkey",
6+
"Retwetkey",
7+
"RGBO",
8+
"userlist"
9+
]
10+
}

android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
2525
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

2727
android {
28-
compileSdkVersion 29
28+
compileSdkVersion 32
2929

3030
lintOptions {
3131
disable 'InvalidPackage'

android/app/src/main/AndroidManifest.xml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<uses-permission android:name="android.permission.INTERNET"/>
1010
<uses-permission android:name="android.permission.CAMERA"/>
1111
<application
12-
android:name="io.flutter.app.FlutterApplication"
1312
android:label="Fwitter"
1413
android:icon="@mipmap/ic_launcher"
1514
android:usesCleartextTraffic="true"

lib/helper/utility.dart

+21-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import '../widgets/newWidget/customLoader.dart';
1717

1818
final kAnalytics = FirebaseAnalytics.instance;
1919
final DatabaseReference kDatabase = FirebaseDatabase.instance.ref();
20-
final kScreenloader = CustomLoader();
20+
final kScreenLoader = CustomLoader();
2121
void cprint(dynamic data,
2222
{String? errorIn, String? event, String label = 'Log'}) {
2323
/// Print logs only in development mode
@@ -49,7 +49,7 @@ class Utility {
4949
return dat;
5050
}
5151

52-
static String getdob(String? date) {
52+
static String getDob(String? date) {
5353
if (date == null || date.isEmpty) {
5454
return '';
5555
}
@@ -101,12 +101,12 @@ class Utility {
101101
static String getPollTime(String date) {
102102
int hr, mm;
103103
String msg = 'Poll ended';
104-
var enddate = DateTime.parse(date);
105-
if (DateTime.now().isAfter(enddate)) {
104+
var endDate = DateTime.parse(date);
105+
if (DateTime.now().isAfter(endDate)) {
106106
return msg;
107107
}
108108
msg = 'Poll ended in';
109-
var dur = enddate.difference(DateTime.now());
109+
var dur = endDate.difference(DateTime.now());
110110
hr = dur.inHours - dur.inDays * 24;
111111
mm = dur.inMinutes - (dur.inHours * 60);
112112
if (dur.inDays > 0) {
@@ -143,8 +143,12 @@ class Utility {
143143
}
144144

145145
static launchURL(String url) async {
146-
if (await canLaunch(url)) {
147-
await launch(url);
146+
if (url == "") {
147+
return;
148+
}
149+
final uri = Uri.parse(url);
150+
if (await canLaunchUrl(uri)) {
151+
await launchURL(url);
148152
} else {
149153
cprint('Could not launch $url');
150154
}
@@ -206,7 +210,7 @@ class Utility {
206210
return false;
207211
}
208212

209-
var status = validateEmal(email);
213+
var status = validateEmail(email);
210214
if (!status) {
211215
customSnackBar(_scaffoldKey, 'Please enter valid email id');
212216
return false;
@@ -232,7 +236,7 @@ class Utility {
232236
_scaffoldKey.currentState!.showSnackBar(snackBar);
233237
}
234238

235-
static bool validateEmal(String email) {
239+
static bool validateEmail(String email) {
236240
String p =
237241
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
238242

@@ -245,13 +249,14 @@ class Utility {
245249
static Future<Uri> createLinkToShare(BuildContext context, String id,
246250
{required SocialMetaTagParameters socialMetaTagParameters}) async {
247251
final DynamicLinkParameters parameters = DynamicLinkParameters(
248-
uriPrefix: 'https://fwitterdev.page.link',
249-
link: Uri.parse('https://twitter.com/$id'),
250-
androidParameters: AndroidParameters(
251-
packageName: 'com.thealphamerc.fwitter_dev',
252-
minimumVersion: 0,
253-
),
254-
socialMetaTagParameters: socialMetaTagParameters);
252+
uriPrefix: 'https://fwitter.page.link',
253+
link: Uri.parse('https://twitter.com/$id'),
254+
androidParameters: AndroidParameters(
255+
packageName: 'com.thealphamerc.flutter_twitter_clone_dev',
256+
minimumVersion: 0,
257+
),
258+
socialMetaTagParameters: socialMetaTagParameters,
259+
);
255260
Uri url;
256261
final ShortDynamicLink shortLink =
257262
await FirebaseDynamicLinks.instance.buildShortLink(parameters);

lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MyApp extends StatelessWidget {
4141
],
4242
child: MaterialApp(
4343
title: 'Fwitter',
44-
theme: AppTheme.apptheme.copyWith(
44+
theme: AppTheme.appTheme.copyWith(
4545
textTheme: GoogleFonts.mulishTextTheme(
4646
Theme.of(context).textTheme,
4747
),

lib/state/appState.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AppState extends ChangeNotifier {
1515
return _pageIndex;
1616
}
1717

18-
set setpageIndex(int index) {
18+
set setPageIndex(int index) {
1919
_pageIndex = index;
2020
notifyListeners();
2121
}

lib/state/base/tweetBaseState.dart

+17-17
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import 'package:flutter_twitter_clone/state/appState.dart';
1010
class TweetBaseState extends AppState {
1111
/// get [Tweet Detail] from firebase realtime kDatabase
1212
/// If model is null then fetch tweet from firebase
13-
/// [getpostDetailFromDatabase] is used to set prepare Tweetr to display Tweet detail
14-
/// After getting tweet detail fetch tweet coments from firebase
15-
Future<FeedModel?> getpostDetailFromDatabase(String postID) async {
13+
/// [getPostDetailFromDatabase] is used to set prepare Tweet to display Tweet detail
14+
/// After getting tweet detail fetch tweet comments from firebase
15+
Future<FeedModel?> getPostDetailFromDatabase(String postID) async {
1616
try {
1717
late FeedModel tweet;
1818

@@ -31,13 +31,13 @@ class TweetBaseState extends AppState {
3131
return tweet;
3232
});
3333
} catch (error) {
34-
cprint(error, errorIn: 'getpostDetailFromDatabase');
34+
cprint(error, errorIn: 'getPostDetailFromDatabase');
3535
return null;
3636
}
3737
}
3838

3939
Future<List<FeedModel>?> getTweetsComments(FeedModel post) async {
40-
late List<FeedModel> _commentlist;
40+
late List<FeedModel> _commentList;
4141
// Check if parent tweet has reply tweets or not
4242
if (post.replyTweetKeyList != null && post.replyTweetKeyList!.isNotEmpty) {
4343
// for (String? x in post.replyTweetKeyList!) {
@@ -46,7 +46,7 @@ class TweetBaseState extends AppState {
4646
// }
4747
// }
4848
//FIXME
49-
_commentlist = [];
49+
_commentList = [];
5050
for (String? replyTweetId in post.replyTweetKeyList!) {
5151
if (replyTweetId != null) {
5252
await kDatabase
@@ -56,27 +56,27 @@ class TweetBaseState extends AppState {
5656
.then((DatabaseEvent event) {
5757
final snapshot = event.snapshot;
5858
if (snapshot.value != null) {
59-
var commentmodel = FeedModel.fromJson(snapshot.value as Map);
59+
var commentModel = FeedModel.fromJson(snapshot.value as Map);
6060
var key = snapshot.key!;
61-
commentmodel.key = key;
61+
commentModel.key = key;
6262

6363
/// add comment tweet to list if tweet is not present in [comment tweet ]list
64-
/// To reduce duplicacy
65-
if (!_commentlist.any((x) => x.key == key)) {
66-
_commentlist.add(commentmodel);
64+
/// To reduce delicacy
65+
if (!_commentList.any((x) => x.key == key)) {
66+
_commentList.add(commentModel);
6767
}
6868
} else {}
6969
if (replyTweetId == post.replyTweetKeyList!.last) {
7070
/// Sort comment by time
7171
/// It helps to display newest Tweet first.
72-
_commentlist.sort((x, y) => DateTime.parse(y.createdAt)
72+
_commentList.sort((x, y) => DateTime.parse(y.createdAt)
7373
.compareTo(DateTime.parse(x.createdAt)));
7474
}
7575
});
7676
}
7777
}
7878
}
79-
return _commentlist;
79+
return _commentList;
8080
}
8181

8282
/// [Delete tweet] in Firebase kDatabase
@@ -118,7 +118,7 @@ class TweetBaseState extends AppState {
118118
tweet.likeList!.add(userId);
119119
tweet.likeCount = tweet.likeCount! + 1;
120120
}
121-
// update likelist of a tweet
121+
// update likeList of a tweet
122122
kDatabase
123123
.child('tweet')
124124
.child(tweet.key!)
@@ -146,9 +146,9 @@ class TweetBaseState extends AppState {
146146
/// Returns new tweet id
147147
String? createPost(FeedModel tweet) {
148148
var json = tweet.toJson();
149-
var refence = kDatabase.child('tweet').push();
150-
refence.set(json);
151-
return refence.key;
149+
var reference = kDatabase.child('tweet').push();
150+
reference.set(json);
151+
return reference.key;
152152
}
153153

154154
/// upload [file] to firebase storage and return its path url

lib/state/chats/chatState.dart

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:flutter_twitter_clone/model/user.dart';
1010
import 'package:flutter_twitter_clone/state/appState.dart';
1111

1212
class ChatState extends AppState {
13-
late bool setIsChatScreenOpen; //!obselete
13+
late bool setIsChatScreenOpen; //!obsolete
1414
final FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
1515

1616
List<ChatMessage>? _messageList;
@@ -28,7 +28,7 @@ class ChatState extends AppState {
2828
Query? messageQuery;
2929

3030
/// Contains list of chat messages on main chat screen
31-
/// List is sortBy mesage timeStamp
31+
/// List is sortBy message timeStamp
3232
/// Last message will be display on the bottom of screen
3333
List<ChatMessage>? get messageList {
3434
if (_messageList == null) {
@@ -67,22 +67,22 @@ class ChatState extends AppState {
6767
}
6868
}
6969

70-
/// Fecth FCM server key from firebase Remote config
70+
/// Fetch FCM server key from firebase Remote config
7171
/// FCM server key is stored in firebase remote config
7272
/// you have to add server key in firebase remote config
7373
/// To fetch this key go to project setting in firebase
7474
/// Click on `cloud messaging` tab
7575
/// Copy server key from `Project credentials`
76-
/// Now goto `Remote Congig` section in fireabse
77-
/// Add [FcmServerKey] as paramerter key and below json in Default vslue
76+
/// Now goto `Remote Config` section in Firebase
77+
/// Add [FcmServerKey] as parameter key and below json in Default value
7878
/// ``` json
7979
/// {
8080
/// "key": "FCM server key here"
8181
/// } ```
8282
/// For more detail visit:- https://github.com/TheAlphamerc/flutter_twitter_clone/issues/28#issue-611695533
8383
/// For package detail check:- https://pub.dev/packages/firebase_remote_config#-readme-tab-
8484
void getFCMServerKey() async {
85-
final RemoteConfig remoteConfig = RemoteConfig.instance;
85+
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
8686
await remoteConfig.fetchAndActivate();
8787
// await remoteConfig.
8888
var data = remoteConfig.getString('FcmServerKey');
@@ -95,7 +95,7 @@ class ChatState extends AppState {
9595
}
9696

9797
/// Fetch users list to who have ever engaged in chat message with logged-in user
98-
void getUserchatList(String userId) {
98+
void getUserChatList(String userId) {
9999
try {
100100
kDatabase
101101
.child('chatUsers')
@@ -135,10 +135,10 @@ class ChatState extends AppState {
135135
}
136136
}
137137

138-
/// Fetch chat all chat messages
138+
/// Fetch all chat messages
139139
/// `_channelName` is used as primary key for chat message table
140140
/// `_channelName` is created from by combining first 5 letters from user ids of two users
141-
void getchatDetailAsync() async {
141+
void getChatDetailAsync() async {
142142
try {
143143
kDatabase
144144
.child('chats')
@@ -210,7 +210,7 @@ class ChatState extends AppState {
210210
return _channelName!;
211211
}
212212

213-
/// Method will trigger every time when you send/recieve from/to someone messgae.
213+
/// Method will trigger every time when you send/receive from/to someone message.
214214
void _onMessageAdded(DatabaseEvent event) {
215215
_messageList ??= <ChatMessage>[];
216216
if (event.snapshot.value != null) {
@@ -271,7 +271,7 @@ class ChatState extends AppState {
271271
notifyListeners();
272272
}
273273

274-
// update last message on chat user list screen when manin chat screen get closed.
274+
// update last message on chat user list screen when main chat screen get closed.
275275
void onChatScreenClosed() {
276276
if (_chatUserList != null &&
277277
_chatUserList!.isNotEmpty &&

0 commit comments

Comments
 (0)