mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Start Flutter update
This commit is contained in:
@ -41,7 +41,7 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
||||
try {
|
||||
final file = await _getFilePath();
|
||||
|
||||
if (!await file.exists()) return _cache = List();
|
||||
if (!await file.exists()) return _cache = [];
|
||||
|
||||
final List<dynamic> json = jsonDecode(await file.readAsString());
|
||||
_cache = json.cast<Map<String, dynamic>>().map(parse).toList();
|
||||
@ -49,7 +49,7 @@ abstract class BaseSerializationHelper<T extends SerializableElement> {
|
||||
_cache.sort();
|
||||
} catch (e, s) {
|
||||
print("Failed to read serialized data! $e => $s");
|
||||
_cache = List();
|
||||
_cache = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class UsersHelper {
|
||||
/// the server, otherwise cached data will be used if available
|
||||
Future<UsersList> getUsersInfo(List<int> users,
|
||||
{bool forceDownload = false}) async {
|
||||
List<int> toDownload = List();
|
||||
List<int> toDownload = [];
|
||||
UsersList list = UsersList();
|
||||
|
||||
// Check cache
|
||||
|
@ -5,7 +5,7 @@ import 'dart:collection';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class AbstractList<E> extends ListBase<E> {
|
||||
final _list = List<E>();
|
||||
final _list = <E>[];
|
||||
|
||||
int get length => _list.length;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import 'package:comunic/models/comment.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class CommentsList extends ListBase<Comment> {
|
||||
List<Comment> _list = List();
|
||||
List<Comment> _list = [];
|
||||
|
||||
int get length => _list.length;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import 'package:comunic/models/conversation_message.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class ConversationMessagesList extends ListBase<ConversationMessage> {
|
||||
final List<ConversationMessage> _list = List();
|
||||
final List<ConversationMessage> _list = [];
|
||||
|
||||
set length(int v) => _list.length = v;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import 'package:comunic/models/conversation.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class ConversationsList extends ListBase<Conversation> {
|
||||
final List<Conversation> _list = List();
|
||||
final List<Conversation> _list = [];
|
||||
UsersList users;
|
||||
|
||||
set length(l) => _list.length = l;
|
||||
|
@ -7,7 +7,7 @@ import 'package:comunic/models/friend.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class FriendsList extends ListBase<Friend> {
|
||||
List<Friend> _list = List();
|
||||
List<Friend> _list = [];
|
||||
|
||||
int get length => _list.length;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import 'package:comunic/models/post.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class PostsList extends ListBase<Post> {
|
||||
List<Post> _list = List();
|
||||
List<Post> _list = [];
|
||||
|
||||
int get length => _list.length;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import 'package:comunic/models/user.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class UsersList extends ListBase<User> {
|
||||
List<User> _list = List();
|
||||
List<User> _list = [];
|
||||
|
||||
int get length => _list.length;
|
||||
|
||||
|
@ -94,7 +94,7 @@ Future<BytesFile> showPickFileDialog({
|
||||
assert(allowedMimeTypes != null);
|
||||
|
||||
// Get the list of allowed extension
|
||||
final allowedExtensions = List<String>();
|
||||
final allowedExtensions = <String>[];
|
||||
for (var mime in allowedExtensions) {
|
||||
final ext = extensionFromMime(mime);
|
||||
if (ext != mime) allowedExtensions.add(ext);
|
||||
|
@ -79,7 +79,7 @@ class _ConversationRouteState extends SafeState<ConversationRoute> {
|
||||
return buildErrorCard(
|
||||
tr("Could not get conversation information!"),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
onPressed: _loadConversation,
|
||||
child: Text(
|
||||
tr("Try again").toUpperCase(),
|
||||
|
@ -146,14 +146,14 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> {
|
||||
children: <Widget>[
|
||||
Text(tr("Here are your options to reset your account:")),
|
||||
_Spacer(),
|
||||
OutlineButton.icon(
|
||||
OutlinedButton.icon(
|
||||
onPressed: _openSendEmailDialog,
|
||||
icon: Icon(Icons.email),
|
||||
label: Text(tr("Send us an email to ask for help")),
|
||||
),
|
||||
_Spacer(visible: _hasSecurityQuestions),
|
||||
_hasSecurityQuestions
|
||||
? OutlineButton.icon(
|
||||
? OutlinedButton.icon(
|
||||
onPressed: _loadSecurityQuestions,
|
||||
icon: Icon(Icons.help_outline),
|
||||
label: Text(tr("Answer your security questions")),
|
||||
@ -199,7 +199,7 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> {
|
||||
..add(_Spacer())
|
||||
..addAll(List.generate(_questions.length, _buildSecurityQuestionField))
|
||||
..add(_Spacer())
|
||||
..add(OutlineButton(
|
||||
..add(OutlinedButton(
|
||||
onPressed: _canSubmitAnswers ? _submitSecurityAnswers : null,
|
||||
child: Text(tr("Submit")),
|
||||
)),
|
||||
|
@ -201,7 +201,6 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
||||
subtitle: _admins.contains(user.id) ? tr("Admin") : tr("Member"),
|
||||
trailing: _canAddMembers
|
||||
? PopupMenuButton<_MembersMenuChoices>(
|
||||
captureInheritedThemes: false,
|
||||
onSelected: (choice) => _membersMenuItemSelected(user, choice),
|
||||
itemBuilder: (c) => <PopupMenuEntry<_MembersMenuChoices>>[
|
||||
PopupMenuItem(
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:comunic/enums/post_kind.dart';
|
||||
import 'package:comunic/enums/post_target.dart';
|
||||
import 'package:comunic/enums/post_visibility_level.dart';
|
||||
@ -12,7 +11,7 @@ import 'package:comunic/utils/files_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/post_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:file_picker_cross/file_picker_cross.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
@ -278,15 +277,18 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
/// Pick a PDF for the new post
|
||||
Future<void> _pickPDFForPost() async {
|
||||
try {
|
||||
final picker = await FilePickerCross.importFromStorage(
|
||||
type: FileTypeCross.custom,
|
||||
fileExtension: "pdf",
|
||||
final file = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ["pdf"],
|
||||
withData: true,
|
||||
);
|
||||
|
||||
if (file == null || file.files.isEmpty) return;
|
||||
|
||||
_resetPostSelection();
|
||||
|
||||
setState(() {
|
||||
this._postPDF = picker.toUint8List();
|
||||
this._postPDF = file.files.first.bytes;
|
||||
});
|
||||
} catch (e, stack) {
|
||||
print("Pick PDF error: $e\n$stack");
|
||||
|
@ -8,8 +8,8 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
abstract class SafeState<T extends StatefulWidget> extends State<T> {
|
||||
final _subscriptions = List<StreamSubscription>();
|
||||
final _timers = List<Timer>();
|
||||
final _subscriptions = <StreamSubscription>[];
|
||||
final _timers = <Timer>[];
|
||||
|
||||
bool _unmounted = false;
|
||||
|
||||
|
@ -123,7 +123,7 @@ class _UserPageTabletState extends State<UserPageTablet> {
|
||||
// Friends list of the user
|
||||
_userInfo.isFriendsListPublic
|
||||
? Expanded(
|
||||
child: OutlineButton.icon(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => MainController.of(context)
|
||||
.openUserFriendsList(_userInfo.id),
|
||||
icon: Icon(Icons.group),
|
||||
|
@ -27,7 +27,7 @@ class TextRichContentWidget extends StatelessWidget {
|
||||
static List<TextSpan> _parse(String text, TextStyle style) {
|
||||
if (style == null) style = TextStyle();
|
||||
|
||||
List<TextSpan> list = List();
|
||||
List<TextSpan> list = [];
|
||||
String currString = "";
|
||||
|
||||
text.split("\n").forEach((f) {
|
||||
|
@ -55,7 +55,7 @@ class TextWidget extends StatelessWidget {
|
||||
List<InlineSpan> _parseLinks(
|
||||
BuildContext context, String text, TextStyle style) {
|
||||
var buff = StringBuffer();
|
||||
final list = new List<InlineSpan>();
|
||||
final list = <InlineSpan>[];
|
||||
|
||||
// Change word function
|
||||
final changeWordType = () {
|
||||
|
@ -27,7 +27,7 @@ class _UserWritingInConvNotifierState
|
||||
extends SafeState<UserWritingInConvNotifier> {
|
||||
final _usersInfo = UsersList();
|
||||
|
||||
final _list = List();
|
||||
final _list = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -226,7 +226,7 @@ class _Element {
|
||||
/// Note : if text is not null, children must be empty !!!
|
||||
String text;
|
||||
final _ElementStyle style;
|
||||
final List<_Element> children = List();
|
||||
final List<_Element> children = [];
|
||||
|
||||
_Element({@required this.style, this.text});
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
/// Transform a list of dynamic thins into something a list of ints
|
||||
List<int> listToIntList(List<dynamic> srcList) {
|
||||
List<int> list = List();
|
||||
List<int> list = [];
|
||||
|
||||
srcList.forEach((e) {
|
||||
list.add(int.parse(e));
|
||||
@ -15,7 +15,7 @@ List<int> listToIntList(List<dynamic> srcList) {
|
||||
|
||||
/// Find the list of missing elements of a [testList] from a [srcList]
|
||||
List<T> findMissingFromList<T>(List<T> srcList, List<T> testList) {
|
||||
List<T> dest = List();
|
||||
List<T> dest = [];
|
||||
|
||||
testList.forEach((f) {
|
||||
if (!srcList.contains(f) && !dest.contains(f)) dest.add(f);
|
||||
|
@ -80,11 +80,11 @@ void showImageFullScreen(BuildContext context, String url) {
|
||||
|
||||
/// Show simple snack
|
||||
void showSimpleSnack(BuildContext context, String message) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
void snack(BuildContext context, String message) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
|
||||
/// Show an alert dialog to ask the user to enter a string
|
||||
@ -194,7 +194,7 @@ Future<bool> showConfirmDialog({
|
||||
if (title == null) title = tr("Confirm operation");
|
||||
|
||||
// Avoid potential theme issues
|
||||
final scaffold = Scaffold.of(context, nullOk: true);
|
||||
final scaffold = Scaffold.maybeOf(context);
|
||||
final ctx = scaffold != null ? scaffold.context : context;
|
||||
|
||||
final result = await showDialog<bool>(
|
||||
|
Reference in New Issue
Block a user