Skip to content

Commit 5dc2e22

Browse files
committed
🐛 Add http request support configuration in android
⬆️ Upgrade flutter sdk constraints. 🐛 removed hash work detection from link preview regex. ⬆️ upgrade list literals to support listerals
1 parent 3cb7a5e commit 5dc2e22

13 files changed

+77
-50
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<application
1111
android:name="io.flutter.app.FlutterApplication"
1212
android:label="Fwitter"
13-
android:icon="@mipmap/ic_launcher">
13+
android:icon="@mipmap/ic_launcher"
14+
android:usesCleartextTraffic="true"
15+
>
1416
<activity
1517
android:name=".MainActivity"
1618
android:launchMode="singleTop"
@@ -35,6 +37,8 @@
3537
android:name="io.flutter.embedding.android.SplashScreenDrawable"
3638
android:resource="@drawable/launch_background"
3739
/>
40+
<meta-data android:name="io.flutter.network-policy"
41+
android:resource="@xml/network_security_config"/>
3842
<intent-filter>
3943
<action android:name="android.intent.action.MAIN"/>
4044
<category android:name="android.intent.category.LAUNCHER"/>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<base-config cleartextTrafficPermitted="true">
4+
<trust-anchors>
5+
<certificates src="system" />
6+
</trust-anchors>
7+
</base-config>
8+
</network-security-config>

lib/helper/utility.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Utility {
165165
RegExp reg = RegExp(
166166
r"([#])\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
167167
Iterable<Match> _matches = reg.allMatches(text);
168-
List<String> resultMatches = List<String>();
168+
List<String> resultMatches = <String>[];
169169
for (Match match in _matches) {
170170
if (match.group(0).isNotEmpty) {
171171
var tag = match.group(0);

lib/model/feedModel.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ class FeedModel {
6565
parentkey = map['parentkey'];
6666
childRetwetkey = map['childRetwetkey'];
6767
if (map['tags'] != null) {
68-
tags = List<String>();
68+
tags = <String>[];
6969
map['tags'].forEach((value) {
7070
tags.add(value);
7171
});
7272
}
7373
if (map["likeList"] != null) {
74-
likeList = List<String>();
74+
likeList = <String>[];
7575

7676
final list = map['likeList'];
7777

@@ -101,7 +101,7 @@ class FeedModel {
101101
}
102102
if (map['replyTweetKeyList'] != null) {
103103
map['replyTweetKeyList'].forEach((value) {
104-
replyTweetKeyList = List<String>();
104+
replyTweetKeyList = <String>[];
105105
map['replyTweetKeyList'].forEach((value) {
106106
replyTweetKeyList.add(value);
107107
});

lib/state/chats/chatState.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ChatState extends AppState {
102102
.child(userId)
103103
.once()
104104
.then((DataSnapshot snapshot) {
105-
_chatUserList = List<ChatMessage>();
105+
_chatUserList = <ChatMessage>[];
106106
if (snapshot.value != null) {
107107
var map = snapshot.value;
108108
if (map != null) {
@@ -144,7 +144,7 @@ class ChatState extends AppState {
144144
.child(_channelName)
145145
.once()
146146
.then((DataSnapshot snapshot) {
147-
_messageList = List<ChatMessage>();
147+
_messageList = <ChatMessage>[];
148148
if (snapshot.value != null) {
149149
var map = snapshot.value;
150150
if (map != null) {
@@ -205,7 +205,7 @@ class ChatState extends AppState {
205205
/// Method will trigger every time when you send/recieve from/to someone messgae.
206206
void _onMessageAdded(Event event) {
207207
if (_messageList == null) {
208-
_messageList = List<ChatMessage>();
208+
_messageList = <ChatMessage>[];
209209
}
210210
if (event.snapshot.value != null) {
211211
var map = event.snapshot.value;
@@ -226,7 +226,7 @@ class ChatState extends AppState {
226226

227227
void _onMessageChanged(Event event) {
228228
if (_messageList == null) {
229-
_messageList = List<ChatMessage>();
229+
_messageList = <ChatMessage>[];
230230
}
231231
if (event.snapshot.value != null) {
232232
var map = event.snapshot.value;
@@ -247,7 +247,7 @@ class ChatState extends AppState {
247247

248248
void _onChatUserAdded(Event event) {
249249
if (_chatUserList == null) {
250-
_chatUserList = List<ChatMessage>();
250+
_chatUserList = <ChatMessage>[];
251251
}
252252
if (event.snapshot.value != null) {
253253
var map = event.snapshot.value;

lib/state/feedState.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class FeedState extends AppState {
141141
_feedlist = null;
142142
notifyListeners();
143143
kDatabase.child('tweet').once().then((DataSnapshot snapshot) {
144-
_feedlist = List<FeedModel>();
144+
_feedlist = <FeedModel>[];
145145
if (snapshot.value != null) {
146146
var map = snapshot.value;
147147
if (map != null) {
@@ -201,7 +201,7 @@ class FeedState extends AppState {
201201

202202
if (_tweetDetail != null) {
203203
// Fetch comment tweets
204-
_commentlist = List<FeedModel>();
204+
_commentlist = <FeedModel>[];
205205
// Check if parent tweet has reply tweets or not
206206
if (_tweetDetail.replyTweetKeyList != null &&
207207
_tweetDetail.replyTweetKeyList.length > 0) {
@@ -489,7 +489,7 @@ class FeedState extends AppState {
489489
_onCommentAdded(tweet);
490490
tweet.key = event.snapshot.key;
491491
if (_feedlist == null) {
492-
_feedlist = List<FeedModel>();
492+
_feedlist = <FeedModel>[];
493493
}
494494
if ((_feedlist.length == 0 || _feedlist.any((x) => x.key != tweet.key)) &&
495495
tweet.isValidTweet) {

lib/state/notificationState.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class NotificationState extends AppState {
127127
var model = NotificationModel.fromJson(event.snapshot.key,
128128
event.snapshot.value["updatedAt"], event.snapshot.value["type"]);
129129
if (_notificationList == null) {
130-
_notificationList = List<NotificationModel>();
130+
_notificationList = <NotificationModel>[];
131131
}
132132
_notificationList.add(model);
133133
// added notification to list

lib/state/searchState.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class SearchState extends AppState {
2424
isBusy = true;
2525
kDatabase.child('profile').once().then(
2626
(DataSnapshot snapshot) {
27-
_userlist = List<UserModel>();
28-
_userFilterlist = List<UserModel>();
27+
_userlist = <UserModel>[];
28+
_userFilterlist = <UserModel>[];
2929
if (snapshot.value != null) {
3030
var map = snapshot.value;
3131
if (map != null) {

lib/widgets/url_text/customUrlText.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class UrlText extends StatelessWidget {
1212
UrlText({this.text, this.style, this.urlStyle, this.onHashTagPressed});
1313

1414
List<InlineSpan> getTextSpans() {
15-
List<InlineSpan> widgets = List<InlineSpan>();
15+
List<InlineSpan> widgets = <InlineSpan>[];
1616
RegExp reg = RegExp(
1717
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
1818
Iterable<Match> _matches = reg.allMatches(text);
19-
List<_ResultMatch> resultMatches = List<_ResultMatch>();
19+
List<_ResultMatch> resultMatches = <_ResultMatch>[];
2020
int start = 0;
2121
for (Match match in _matches) {
2222
if (match.group(0).isNotEmpty) {
@@ -59,6 +59,7 @@ class UrlText extends StatelessWidget {
5959
@override
6060
Widget build(BuildContext context) {
6161
return Column(
62+
crossAxisAlignment: CrossAxisAlignment.start,
6263
children: [
6364
RichText(
6465
text: TextSpan(children: getTextSpans()),

lib/widgets/url_text/custom_link_media_info.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CustomLinkMediaInfo extends StatelessWidget {
2020
return null;
2121
}
2222
RegExp reg = RegExp(
23-
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
23+
r"(https?|http)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
2424
Iterable<Match> _matches = reg.allMatches(text);
2525
if (_matches.isNotEmpty) {
2626
return _matches.first.group(0);
@@ -125,7 +125,13 @@ class CustomLinkMediaInfo extends StatelessWidget {
125125
),
126126
),
127127
),
128-
Padding(
128+
Container(
129+
decoration: BoxDecoration(
130+
borderRadius: BorderRadius.circular(10),
131+
color: model.thumbnailUrl != null
132+
? Theme.of(context).colorScheme.onPrimary
133+
: const Color(0xFFF0F1F2),
134+
),
129135
padding:
130136
EdgeInsets.only(bottom: 5, left: 8, right: 8, top: 4),
131137
child: Column(

lib/widgets/url_text/link_preview.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LinkPreview extends StatelessWidget {
1717
return null;
1818
}
1919
RegExp reg = RegExp(
20-
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
20+
r"(https?|http)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
2121
Iterable<Match> _matches = reg.allMatches(text);
2222
if (_matches.isNotEmpty) {
2323
return _matches.first.group(0);
@@ -62,7 +62,7 @@ class LinkPreview extends StatelessWidget {
6262
borderRadius: BorderRadius.circular(10),
6363
border: Border.all(color: AppColor.extraLightGrey),
6464
color: webInfo.image != null
65-
? Colors.transparent
65+
? Theme.of(context).colorScheme.onPrimary
6666
: const Color(0xFFF0F1F2),
6767
),
6868
child: Column(

0 commit comments

Comments
 (0)