1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-26 12:58:51 +00:00

Start to add support for Flutter Web

This commit is contained in:
Pierre HUBERT 2021-03-14 17:44:29 +01:00
parent 1aa39ea64f
commit 4a905174bf
5 changed files with 23 additions and 10 deletions

View File

@ -4,7 +4,6 @@
// ignore_for_file: lines_longer_than_80_chars
// ignore: implementation_imports
import 'package:file_picker/src/file_picker_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';

View File

@ -1,3 +1,4 @@
import 'package:comunic/utils/flutter_utils.dart';
import 'package:package_info/package_info.dart';
import 'package:version/version.dart';
@ -9,7 +10,7 @@ class VersionHelper {
static PackageInfo _info;
static Future<void> ensureLoaded() async {
_info = await PackageInfo.fromPlatform();
if (!isWeb) _info = await PackageInfo.fromPlatform();
}
/// Get current version information

View File

@ -3,6 +3,7 @@ import 'package:comunic/helpers/database/database_helper.dart';
import 'package:comunic/helpers/preferences_helper.dart';
import 'package:comunic/helpers/version_helper.dart';
import 'package:comunic/ui/widgets/init_widget.dart';
import 'package:comunic/utils/flutter_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart';
@ -17,8 +18,10 @@ void subMain() async {
await VersionHelper.ensureLoaded();
// Connect to database
await DatabaseHelper.open();
await DatabaseHelper.cleanUpDatabase();
if(!isWeb) {
await DatabaseHelper.open();
await DatabaseHelper.cleanUpDatabase();
}
// Get current system language
await initTranslations();

View File

@ -9,6 +9,7 @@ import 'package:comunic/ui/routes/main_route/main_route.dart';
import 'package:comunic/ui/routes/main_route/smartphone_route.dart';
import 'package:comunic/ui/routes/main_route/tablet_route.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/utils/flutter_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart';
@ -63,8 +64,9 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
try {
await ServerConfigurationHelper.ensureLoaded();
if (ServerConfigurationHelper.config.minSupportedMobileVersion > VersionHelper.version)
await showDeprecationDialog(context);
if (!isWeb &&
ServerConfigurationHelper.config.minSupportedMobileVersion >
VersionHelper.version) await showDeprecationDialog(context);
if (!AccountHelper.isUserIDLoaded) {
_popToMainRoute();
@ -128,10 +130,12 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
Spacer(
flex: 2,
),
Text(tr("Version %version% - Build %build%", args: {
"version": VersionHelper.info.version.toString(),
"build": VersionHelper.info.buildNumber.toString()
})),
!isWeb
? Text(tr("Version %version% - Build %build%", args: {
"version": VersionHelper.info.version.toString(),
"build": VersionHelper.info.buildNumber.toString()
}))
: Container(),
Spacer(flex: 1),
],
),

View File

@ -0,0 +1,6 @@
/// Flutter utilities
///
/// @author Pierre Hubert
import 'package:flutter/foundation.dart' show kIsWeb;
bool get isWeb => kIsWeb;