+1
-1
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:stream_chatter/domain/models/auth_user.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<AuthUser> getAuthUser();
|
||||
Future<AuthUser?> getAuthUser();
|
||||
Future<AuthUser> signIn();
|
||||
Future<void> logout();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
abstract class ImagePickerRepository {
|
||||
Future<File> pickImage();
|
||||
Future<File?> pickImage();
|
||||
}
|
||||
|
||||
@@ -4,10 +4,17 @@ import 'package:stream_chatter/data/image_picker_repository.dart';
|
||||
|
||||
class ImagePickerImpl extends ImagePickerRepository {
|
||||
@override
|
||||
Future<File> pickImage() async {
|
||||
Future<File?> pickImage() async {
|
||||
final picker = ImagePicker();
|
||||
final pickedFile =
|
||||
await picker.getImage(source: ImageSource.gallery, maxWidth: 400);
|
||||
final pickedFile = await picker.getImage(
|
||||
source: ImageSource.gallery,
|
||||
maxWidth: 400,
|
||||
);
|
||||
|
||||
if (pickedFile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return File(pickedFile.path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
final StreamChatClient _client;
|
||||
|
||||
@override
|
||||
Future<ChatUser> connectUser(ChatUser user, String token) async {
|
||||
Future<ChatUser> connectUser(ChatUser user, String? token) async {
|
||||
Map<String, dynamic> extraData = {};
|
||||
if (user.image != null) {
|
||||
extraData['image'] = user.image;
|
||||
@@ -18,7 +18,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
}
|
||||
await _client.disconnect();
|
||||
await _client.connectUser(
|
||||
User(id: user.id, extraData: extraData),
|
||||
User(id: user.id!, extraData: extraData as Map<String, Object>),
|
||||
token,
|
||||
);
|
||||
return user;
|
||||
@@ -28,12 +28,12 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
Future<List<ChatUser>> getChatUsers() async {
|
||||
final result = await _client.queryUsers();
|
||||
final chatUsers = result.users
|
||||
.where((element) => element.id != _client.state.user.id)
|
||||
.where((element) => element.id != _client.state.user!.id)
|
||||
.map(
|
||||
(e) => ChatUser(
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
image: e.extraData['image'],
|
||||
image: e.extraData['image'] as String?,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
@@ -47,25 +47,25 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
|
||||
@override
|
||||
Future<Channel> createGroupChat(
|
||||
String channelId, String name, List<String> members,
|
||||
{String image}) async {
|
||||
String channelId, String? name, List<String?>? members,
|
||||
{String? image}) async {
|
||||
final channel = _client.channel('messaging', id: channelId, extraData: {
|
||||
'name': name,
|
||||
'image': image,
|
||||
'members': [_client.state.user.id, ...members],
|
||||
'name': name!,
|
||||
'image': image!,
|
||||
'members': [_client.state.user!.id, ...members!],
|
||||
});
|
||||
await channel.watch();
|
||||
return channel;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Channel> createSimpleChat(String friendId) async {
|
||||
Future<Channel> createSimpleChat(String? friendId) async {
|
||||
final channel = _client.channel('messaging',
|
||||
id: '${_client.state.user.id.hashCode}${friendId.hashCode}',
|
||||
id: '${_client.state.user!.id.hashCode}${friendId.hashCode}',
|
||||
extraData: {
|
||||
'members': [
|
||||
friendId,
|
||||
_client.state.user.id,
|
||||
_client.state.user!.id,
|
||||
],
|
||||
});
|
||||
await channel.watch();
|
||||
@@ -84,6 +84,6 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
User(id: userId),
|
||||
token,
|
||||
);
|
||||
return _client.state.user.name != null && _client.state.user.name != userId;
|
||||
return _client.state.user!.name != null && _client.state.user!.name != userId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:stream_chatter/data/upload_storage_repository.dart';
|
||||
|
||||
class UploadStorageLocalImpl extends UploadStorageRepository {
|
||||
@override
|
||||
Future<String> uploadPhoto(File file, String path) async {
|
||||
Future<String> uploadPhoto(File? file, String path) async {
|
||||
return 'https://lh3.googleusercontent.com/a-/AOh14GjhqGZ-V7tNXS1pOIp9vbBij4OS9JbzxXgxgy1t=s600-k-no-rp-mo';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class AuthImpl extends AuthRepository {
|
||||
FirebaseAuth _auth = FirebaseAuth.instance;
|
||||
|
||||
@override
|
||||
Future<AuthUser> getAuthUser() async {
|
||||
Future<AuthUser?> getAuthUser() async {
|
||||
final user = _auth.currentUser;
|
||||
if (user != null) {
|
||||
return AuthUser(user.uid);
|
||||
@@ -19,16 +19,21 @@ class AuthImpl extends AuthRepository {
|
||||
Future<AuthUser> signIn() async {
|
||||
try {
|
||||
UserCredential userCredential;
|
||||
final GoogleSignInAccount googleUser = await GoogleSignIn().signIn();
|
||||
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
||||
|
||||
if (googleUser == null) {
|
||||
throw Exception('login error');
|
||||
}
|
||||
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser.authentication;
|
||||
final GoogleAuthCredential googleAuthCredential =
|
||||
GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
) as GoogleAuthCredential;
|
||||
userCredential = await _auth.signInWithCredential(googleAuthCredential);
|
||||
final user = userCredential.user;
|
||||
final user = userCredential.user!;
|
||||
return AuthUser(user.uid);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
||||
@@ -13,6 +13,6 @@ class PersistentStorageImpl extends PersistentStorageRepository {
|
||||
@override
|
||||
Future<void> updateDarkMode(bool isDarkMode) async {
|
||||
final preference = await SharedPreferences.getInstance();
|
||||
return await preference.setBool(_isDarkMode, isDarkMode);
|
||||
await preference.setBool(_isDarkMode, isDarkMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
final StreamChatClient _client;
|
||||
|
||||
@override
|
||||
Future<ChatUser> connectUser(ChatUser user, String token) async {
|
||||
Future<ChatUser> connectUser(ChatUser user, String? token) async {
|
||||
Map<String, dynamic> extraData = {};
|
||||
if (user.image != null) {
|
||||
extraData['image'] = user.image;
|
||||
@@ -21,7 +21,7 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
}
|
||||
await _client.disconnect();
|
||||
await _client.connectUser(
|
||||
User(id: user.id, extraData: extraData),
|
||||
User(id: user.id!, extraData: extraData as Map<String, Object>),
|
||||
token,
|
||||
);
|
||||
return user;
|
||||
@@ -31,12 +31,12 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
Future<List<ChatUser>> getChatUsers() async {
|
||||
final result = await _client.queryUsers();
|
||||
final chatUsers = result.users
|
||||
.where((element) => element.id != _client.state.user.id)
|
||||
.where((element) => element.id != _client.state.user!.id)
|
||||
.map(
|
||||
(e) => ChatUser(
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
image: e.extraData['image'],
|
||||
image: e.extraData['image'] as String?,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
@@ -44,10 +44,10 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getToken(String userId) async {
|
||||
Future<String?> getToken(String userId) async {
|
||||
//TODO: use your own implementation in Production
|
||||
final response = await http.post(
|
||||
'your_backend_url',
|
||||
Uri.parse('your_backend_url'),
|
||||
body: jsonEncode(<String, String>{'id': userId}),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@@ -62,25 +62,25 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Channel> createGroupChat(String id, String name, List<String> members,
|
||||
{String image}) async {
|
||||
Future<Channel> createGroupChat(String id, String? name, List<String?>? members,
|
||||
{String? image}) async {
|
||||
final channel = _client.channel('messaging', id: id, extraData: {
|
||||
'name': name,
|
||||
'image': image,
|
||||
'members': [_client.state.user.id, ...members],
|
||||
'name': name!,
|
||||
'image': image!,
|
||||
'members': [_client.state.user!.id, ...members!],
|
||||
});
|
||||
await channel.watch();
|
||||
return channel;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Channel> createSimpleChat(String friendId) async {
|
||||
Future<Channel> createSimpleChat(String? friendId) async {
|
||||
final channel = _client.channel('messaging',
|
||||
id: '${_client.state.user.id.hashCode}${friendId.hashCode}',
|
||||
id: '${_client.state.user!.id.hashCode}${friendId.hashCode}',
|
||||
extraData: {
|
||||
'members': [
|
||||
friendId,
|
||||
_client.state.user.id,
|
||||
_client.state.user!.id,
|
||||
],
|
||||
});
|
||||
await channel.watch();
|
||||
@@ -99,6 +99,6 @@ class StreamApiImpl extends StreamApiRepository {
|
||||
User(id: userId),
|
||||
token,
|
||||
);
|
||||
return _client.state.user.name != null && _client.state.user.name != userId;
|
||||
return _client.state.user!.name != null && _client.state.user!.name != userId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import 'package:stream_chatter/data/upload_storage_repository.dart';
|
||||
|
||||
class UploadStorageImpl extends UploadStorageRepository {
|
||||
@override
|
||||
Future<String> uploadPhoto(File file, String path) async {
|
||||
Future<String> uploadPhoto(File? file, String path) async {
|
||||
final ref = firebase_storage.FirebaseStorage.instance.ref(path);
|
||||
final uploadTask = ref.putFile(file);
|
||||
final uploadTask = ref.putFile(file!);
|
||||
await uploadTask;
|
||||
return await ref.getDownloadURL();
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
abstract class StreamApiRepository {
|
||||
Future<List<ChatUser>> getChatUsers();
|
||||
Future<String> getToken(String userId);
|
||||
Future<String?> getToken(String userId);
|
||||
Future<bool> connectIfExist(String userId);
|
||||
Future<ChatUser> connectUser(ChatUser user, String token);
|
||||
Future<ChatUser> connectUser(ChatUser user, String? token);
|
||||
Future<Channel> createGroupChat(
|
||||
String channelId, String name, List<String> members,
|
||||
{String image});
|
||||
Future<Channel> createSimpleChat(String friendId);
|
||||
String channelId, String? name, List<String?>? members,
|
||||
{String? image});
|
||||
Future<Channel> createSimpleChat(String? friendId);
|
||||
Future<void> logout();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
abstract class UploadStorageRepository {
|
||||
Future<String> uploadPhoto(File file, String path);
|
||||
Future<String> uploadPhoto(File? file, String path);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ChatUser {
|
||||
const ChatUser({this.name, this.image, this.id});
|
||||
final String name;
|
||||
final String image;
|
||||
final String id;
|
||||
final String? name;
|
||||
final String? image;
|
||||
final String? id;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'package:uuid/uuid.dart';
|
||||
|
||||
class CreateGroupInput {
|
||||
CreateGroupInput({this.imageFile, this.name, this.members});
|
||||
final File imageFile;
|
||||
final String name;
|
||||
final List<String> members;
|
||||
final File? imageFile;
|
||||
final String? name;
|
||||
final List<String?>? members;
|
||||
}
|
||||
|
||||
class CreateGroupUseCase {
|
||||
@@ -23,7 +23,7 @@ class CreateGroupUseCase {
|
||||
|
||||
Future<Channel> createGroup(CreateGroupInput input) async {
|
||||
final channelId = Uuid().v4();
|
||||
String image;
|
||||
String? image;
|
||||
if (input.imageFile != null) {
|
||||
image = await _uploadStorageRepository.uploadPhoto(
|
||||
input.imageFile, 'channels/$channelId');
|
||||
|
||||
@@ -5,10 +5,12 @@ import 'package:stream_chatter/data/stream_api_repository.dart';
|
||||
import 'package:stream_chatter/data/upload_storage_repository.dart';
|
||||
import 'package:stream_chatter/domain/models/chat_user.dart';
|
||||
|
||||
import '../exceptions/auth_exception.dart';
|
||||
|
||||
class ProfileInput {
|
||||
ProfileInput({this.imageFile, this.name});
|
||||
final File imageFile;
|
||||
final String name;
|
||||
final File? imageFile;
|
||||
final String? name;
|
||||
}
|
||||
|
||||
class ProfileSignInUseCase {
|
||||
@@ -24,13 +26,21 @@ class ProfileSignInUseCase {
|
||||
|
||||
Future<void> verify(ProfileInput input) async {
|
||||
final auth = await _authRepository.getAuthUser();
|
||||
if (auth == null) {
|
||||
throw AuthException(AuthErrorCode.not_auth);
|
||||
}
|
||||
final token = await _streamApiRepository.getToken(auth.id);
|
||||
String image;
|
||||
String? image;
|
||||
if (input.imageFile != null) {
|
||||
image = await _uploadStorageRepository.uploadPhoto(
|
||||
input.imageFile, 'users/${auth.id}');
|
||||
}
|
||||
await _streamApiRepository.connectUser(
|
||||
ChatUser(name: input.name, id: auth.id, image: image), token);
|
||||
ChatUser(
|
||||
name: input.name,
|
||||
id: auth.id,
|
||||
image: image,
|
||||
),
|
||||
token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AvatarImageView extends StatelessWidget {
|
||||
const AvatarImageView({Key key, this.onTap, this.child}) : super(key: key);
|
||||
final Widget child;
|
||||
final VoidCallback onTap;
|
||||
const AvatarImageView({Key? key, this.onTap, this.child}) : super(key: key);
|
||||
final Widget? child;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -5,8 +5,8 @@ class LoadingView extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const LoadingView({
|
||||
Key key,
|
||||
@required this.child,
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.isLoading = false,
|
||||
}) : super(key: key);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
@@ -30,22 +31,22 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
/// Modify it to change the widget appearance.
|
||||
class MyChannelPreview extends StatelessWidget {
|
||||
/// Function called when tapping this widget
|
||||
final void Function(Channel) onTap;
|
||||
final void Function(Channel)? onTap;
|
||||
|
||||
/// Function called when long pressing this widget
|
||||
final void Function(Channel) onLongPress;
|
||||
final void Function(Channel)? onLongPress;
|
||||
|
||||
/// Channel displayed
|
||||
final Channel channel;
|
||||
|
||||
/// The function called when the image is tapped
|
||||
final VoidCallback onImageTap;
|
||||
final VoidCallback? onImageTap;
|
||||
|
||||
final String heroTag;
|
||||
final String? heroTag;
|
||||
|
||||
MyChannelPreview({
|
||||
@required this.channel,
|
||||
Key key,
|
||||
required this.channel,
|
||||
Key? key,
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
this.onImageTap,
|
||||
@@ -59,24 +60,24 @@ class MyChannelPreview extends StatelessWidget {
|
||||
initialData: channel.isMuted,
|
||||
builder: (context, snapshot) {
|
||||
return Opacity(
|
||||
opacity: snapshot.data ? 0.5 : 1,
|
||||
opacity: snapshot.data! ? 0.5 : 1,
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
),
|
||||
onTap: () {
|
||||
if (onTap != null) {
|
||||
onTap(channel);
|
||||
onTap!(channel);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (onLongPress != null) {
|
||||
onLongPress(channel);
|
||||
onLongPress!(channel);
|
||||
}
|
||||
},
|
||||
leading: Material(
|
||||
child: Hero(
|
||||
tag: heroTag,
|
||||
tag: heroTag!,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: ChannelImage(
|
||||
@@ -95,13 +96,13 @@ class MyChannelPreview extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
StreamBuilder<List<Member>>(
|
||||
stream: channel.state.membersStream,
|
||||
initialData: channel.state.members,
|
||||
stream: channel.state!.membersStream,
|
||||
initialData: channel.state!.members,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData ||
|
||||
snapshot.data.isEmpty ||
|
||||
!snapshot.data.any((Member e) =>
|
||||
e.user.id == channel.client.state.user.id)) {
|
||||
snapshot.data!.isEmpty ||
|
||||
!snapshot.data!.any((Member e) =>
|
||||
e.user!.id == channel.client.state.user!.id)) {
|
||||
return SizedBox();
|
||||
}
|
||||
return ChannelUnreadIndicator(
|
||||
@@ -116,26 +117,26 @@ class MyChannelPreview extends StatelessWidget {
|
||||
Flexible(child: _buildSubtitle(context)),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final lastMessage = channel.state.messages.lastWhere(
|
||||
final lastMessage =
|
||||
channel.state!.messages.lastWhereOrNull(
|
||||
(m) => !m.isDeleted && m.shadowed != true,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (lastMessage?.user?.id ==
|
||||
StreamChat.of(context).user.id) {
|
||||
StreamChat.of(context).user!.id) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 4.0),
|
||||
child: SendingIndicator(
|
||||
message: lastMessage,
|
||||
message: lastMessage!,
|
||||
size: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.indicatorIconSize,
|
||||
isMessageRead: channel.state.read
|
||||
isMessageRead: channel.state!.read
|
||||
?.where((element) =>
|
||||
element.user.id !=
|
||||
channel.client.state.user.id)
|
||||
?.where((element) => element.lastRead
|
||||
channel.client.state.user!.id)
|
||||
.where((element) => element.lastRead
|
||||
.isAfter(lastMessage.createdAt))
|
||||
?.isNotEmpty ==
|
||||
.isNotEmpty ==
|
||||
true,
|
||||
),
|
||||
);
|
||||
@@ -152,14 +153,14 @@ class MyChannelPreview extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildDate(BuildContext context) {
|
||||
return StreamBuilder<DateTime>(
|
||||
return StreamBuilder<DateTime?>(
|
||||
stream: channel.lastMessageAtStream,
|
||||
initialData: channel.lastMessageAt,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return SizedBox();
|
||||
}
|
||||
final lastMessageAt = snapshot.data.toLocal();
|
||||
final lastMessageAt = snapshot.data!.toLocal();
|
||||
|
||||
String stringDate;
|
||||
final now = DateTime.now();
|
||||
@@ -198,11 +199,11 @@ class MyChannelPreview extends StatelessWidget {
|
||||
' Channel is muted',
|
||||
style: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.subtitle
|
||||
.subtitle!
|
||||
.copyWith(
|
||||
color: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.subtitle
|
||||
.subtitle!
|
||||
.color,
|
||||
),
|
||||
),
|
||||
@@ -212,21 +213,20 @@ class MyChannelPreview extends StatelessWidget {
|
||||
return TypingIndicator(
|
||||
channel: channel,
|
||||
alternativeWidget: _buildLastMessage(context),
|
||||
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle!.copyWith(
|
||||
color:
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle.color,
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle!.color,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLastMessage(BuildContext context) {
|
||||
return StreamBuilder<List<Message>>(
|
||||
stream: channel.state.messagesStream,
|
||||
initialData: channel.state.messages,
|
||||
return StreamBuilder<List<Message>?>(
|
||||
stream: channel.state!.messagesStream,
|
||||
initialData: channel.state!.messages,
|
||||
builder: (context, snapshot) {
|
||||
final lastMessage = snapshot.data?.lastWhere(
|
||||
(m) => m.shadowed != true && !m.isDeleted,
|
||||
orElse: () => null);
|
||||
final lastMessage = snapshot.data
|
||||
?.lastWhereOrNull((m) => m.shadowed != true && !m.isDeleted);
|
||||
if (lastMessage == null) {
|
||||
return SizedBox();
|
||||
}
|
||||
@@ -254,21 +254,21 @@ class MyChannelPreview extends StatelessWidget {
|
||||
|
||||
return Text.rich(
|
||||
_getDisplayText(
|
||||
text,
|
||||
text!,
|
||||
lastMessage.mentionedUsers,
|
||||
lastMessage.attachments,
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle!.copyWith(
|
||||
color: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.subtitle
|
||||
.subtitle!
|
||||
.color,
|
||||
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
|
||||
? FontStyle.italic
|
||||
: FontStyle.normal),
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle!.copyWith(
|
||||
color: StreamChatTheme.of(context)
|
||||
.channelPreviewTheme
|
||||
.subtitle
|
||||
.subtitle!
|
||||
.color,
|
||||
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
|
||||
? FontStyle.italic
|
||||
@@ -321,8 +321,8 @@ class MyChannelPreview extends StatelessWidget {
|
||||
|
||||
class ChannelUnreadIndicator extends StatelessWidget {
|
||||
const ChannelUnreadIndicator({
|
||||
Key key,
|
||||
@required this.channel,
|
||||
Key? key,
|
||||
required this.channel,
|
||||
}) : super(key: key);
|
||||
|
||||
final Channel channel;
|
||||
@@ -330,8 +330,8 @@ class ChannelUnreadIndicator extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder<int>(
|
||||
stream: channel.state.unreadCountStream,
|
||||
initialData: channel.state.unreadCount,
|
||||
stream: channel.state!.unreadCountStream,
|
||||
initialData: channel.state!.unreadCount,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData || snapshot.data == 0) {
|
||||
return SizedBox();
|
||||
@@ -351,7 +351,7 @@ class ChannelUnreadIndicator extends StatelessWidget {
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${snapshot.data > 99 ? '99+' : snapshot.data}',
|
||||
'${snapshot.data! > 99 ? '99+' : snapshot.data}',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.white,
|
||||
|
||||
@@ -23,11 +23,10 @@ class ChatView extends StatelessWidget {
|
||||
),
|
||||
body: ChannelsBloc(
|
||||
child: ChannelListView(
|
||||
filter: {
|
||||
'members': {
|
||||
'\$in': [StreamChat.of(context).user?.id],
|
||||
}
|
||||
},
|
||||
filter: Filter.in_(
|
||||
'members',
|
||||
[StreamChat.of(context).user!.id],
|
||||
),
|
||||
sort: [SortOption('last_message_at')],
|
||||
channelPreviewBuilder: (context, channel) {
|
||||
return Container(
|
||||
@@ -36,22 +35,22 @@ class ChatView extends StatelessWidget {
|
||||
channel: channel,
|
||||
heroTag: channel.id,
|
||||
onImageTap: () {
|
||||
String name;
|
||||
String image;
|
||||
String? name;
|
||||
String? image;
|
||||
final currentUser = StreamChat.of(context).client.state.user;
|
||||
if (channel.isGroup) {
|
||||
name = channel.extraData['name'];
|
||||
image = channel.extraData['image'];
|
||||
} else {
|
||||
final friend = channel.state.members
|
||||
.where((element) => element.userId != currentUser.id)
|
||||
final friend = channel.state!.members
|
||||
.where((element) => element.userId != currentUser!.id)
|
||||
.first
|
||||
.user;
|
||||
.user!;
|
||||
name = friend.name;
|
||||
image = friend.extraData['image'];
|
||||
image = friend.extraData['image'] as String?;
|
||||
}
|
||||
|
||||
return Navigator.of(context).push(
|
||||
Navigator.of(context).push(
|
||||
PageRouteBuilder(
|
||||
barrierColor: Colors.black45,
|
||||
barrierDismissible: true,
|
||||
@@ -110,15 +109,15 @@ class ChannelPage extends StatelessWidget {
|
||||
|
||||
class ChatDetailView extends StatelessWidget {
|
||||
const ChatDetailView({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.image,
|
||||
this.name,
|
||||
this.channelId,
|
||||
}) : super(key: key);
|
||||
|
||||
final String image;
|
||||
final String name;
|
||||
final String channelId;
|
||||
final String? image;
|
||||
final String? name;
|
||||
final String? channelId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -135,10 +134,10 @@ class ChatDetailView extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Hero(
|
||||
tag: channelId,
|
||||
tag: channelId!,
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
image,
|
||||
image!,
|
||||
height: 180,
|
||||
width: 180,
|
||||
fit: BoxFit.cover,
|
||||
@@ -146,7 +145,7 @@ class ChatDetailView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
name,
|
||||
name!,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 22,
|
||||
|
||||
@@ -143,9 +143,9 @@ class FriendsSelectionView extends StatelessWidget {
|
||||
CircleAvatar(
|
||||
radius: 30,
|
||||
backgroundImage: NetworkImage(
|
||||
chatUserState.chatUser.image),
|
||||
chatUserState.chatUser.image!),
|
||||
),
|
||||
Text(chatUserState.chatUser.name),
|
||||
Text(chatUserState.chatUser.name!),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
@@ -178,9 +178,9 @@ class FriendsSelectionView extends StatelessWidget {
|
||||
},
|
||||
leading: CircleAvatar(
|
||||
backgroundImage:
|
||||
NetworkImage(chatUserState.chatUser.image),
|
||||
NetworkImage(chatUserState.chatUser.image!),
|
||||
),
|
||||
title: Text(chatUserState.chatUser.name),
|
||||
title: Text(chatUserState.chatUser.name!),
|
||||
trailing: isGroup
|
||||
? Checkbox(
|
||||
value: chatUserState.selected,
|
||||
|
||||
@@ -13,8 +13,8 @@ class GroupSelectionState {
|
||||
this.channel,
|
||||
this.isLoading = false,
|
||||
});
|
||||
final File file;
|
||||
final Channel channel;
|
||||
final File? file;
|
||||
final Channel? channel;
|
||||
final bool isLoading;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class GroupSelectionView extends StatelessWidget {
|
||||
context,
|
||||
Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: snapshot.channel,
|
||||
channel: snapshot.channel!,
|
||||
child: ChannelPage(),
|
||||
),
|
||||
),
|
||||
@@ -60,9 +60,9 @@ class GroupSelectionView extends StatelessWidget {
|
||||
children: [
|
||||
AvatarImageView(
|
||||
onTap: context.read<GroupSelectionCubit>().pickImage,
|
||||
child: snapshot?.file != null
|
||||
child: snapshot.file != null
|
||||
? Image.file(
|
||||
snapshot?.file,
|
||||
snapshot.file!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Icon(
|
||||
@@ -104,9 +104,9 @@ class GroupSelectionView extends StatelessWidget {
|
||||
CircleAvatar(
|
||||
radius: 30,
|
||||
backgroundImage:
|
||||
NetworkImage(chatUserState.chatUser.image),
|
||||
NetworkImage(chatUserState.chatUser.image!),
|
||||
),
|
||||
Text(chatUserState.chatUser.name),
|
||||
Text(chatUserState.chatUser.name!),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ class HomeView extends StatelessWidget {
|
||||
|
||||
class HomeNavigationBar extends StatelessWidget {
|
||||
const HomeNavigationBar({
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -110,16 +110,16 @@ class HomeNavigationBar extends StatelessWidget {
|
||||
|
||||
class _HomeNavItem extends StatelessWidget {
|
||||
const _HomeNavItem({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.iconData,
|
||||
this.text,
|
||||
this.onTap,
|
||||
this.selected = false,
|
||||
}) : super(key: key);
|
||||
|
||||
final IconData iconData;
|
||||
final String text;
|
||||
final VoidCallback onTap;
|
||||
final IconData? iconData;
|
||||
final String? text;
|
||||
final VoidCallback? onTap;
|
||||
final bool selected;
|
||||
|
||||
@override
|
||||
@@ -135,7 +135,7 @@ class _HomeNavItem extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(iconData, color: color),
|
||||
Text(text, style: TextStyle(color: color)),
|
||||
Text(text!, style: TextStyle(color: color)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
class SettingsView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = StreamChat.of(context).client.state.user;
|
||||
final image = user?.extraData['image'];
|
||||
final user = StreamChat.of(context).client.state.user!;
|
||||
final image = user.extraData['image'];
|
||||
final textColor = Theme.of(context).appBarTheme.color;
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
@@ -48,7 +48,7 @@ class SettingsView extends StatelessWidget {
|
||||
onTap: () => null,
|
||||
child: image != null
|
||||
? Image.network(
|
||||
image,
|
||||
image as String,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Icon(
|
||||
|
||||
@@ -11,7 +11,7 @@ class ProfileState {
|
||||
this.success = false,
|
||||
this.loading = false,
|
||||
});
|
||||
final File file;
|
||||
final File? file;
|
||||
final bool success;
|
||||
final bool loading;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class ProfileVerifyView extends StatelessWidget {
|
||||
onTap: context.read<ProfileVerifyCubit>().pickImage,
|
||||
child: snapshot.file != null
|
||||
? Image.file(
|
||||
snapshot.file,
|
||||
snapshot.file!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Icon(
|
||||
|
||||
@@ -4,22 +4,23 @@ publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
flutter_bloc: 6.1.2
|
||||
stream_chat_flutter: 1.3.0-beta
|
||||
uuid: 2.2.2
|
||||
flutter_bloc: ^7.0.0
|
||||
stream_chat_flutter: ^2.0.0-nullsafety.3
|
||||
uuid: ^3.0.4
|
||||
|
||||
firebase_core: 0.7.0
|
||||
google_sign_in: 4.5.9
|
||||
firebase_auth: 0.20.0+1
|
||||
firebase_storage: 7.0.0
|
||||
shared_preferences: 0.5.12+4
|
||||
firebase_core: ^1.2.0
|
||||
google_sign_in: ^5.0.3
|
||||
firebase_auth: ^1.2.0
|
||||
firebase_storage: ^8.1.0
|
||||
shared_preferences: ^2.0.5
|
||||
http: any
|
||||
collection: ^1.15.0-nullsafety.4
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user