feat: Enable macOS build
This commit is contained in:
parent
27e6b324c0
commit
f98f87db8e
35 changed files with 1590 additions and 68 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
|
@ -201,10 +202,10 @@ class Store {
|
|||
|
||||
Store()
|
||||
: storage = LocalStorage('LocalStorage'),
|
||||
secureStorage = kIsWeb ? null : FlutterSecureStorage();
|
||||
secureStorage = PlatformInfos.isMobile ? FlutterSecureStorage() : null;
|
||||
|
||||
Future<dynamic> getItem(String key) async {
|
||||
if (kIsWeb) {
|
||||
if (!PlatformInfos.isMobile) {
|
||||
await storage.ready;
|
||||
try {
|
||||
return await storage.getItem(key);
|
||||
|
|
@ -220,7 +221,7 @@ class Store {
|
|||
}
|
||||
|
||||
Future<void> setItem(String key, String value) async {
|
||||
if (kIsWeb) {
|
||||
if (!PlatformInfos.isMobile) {
|
||||
await storage.ready;
|
||||
return await storage.setItem(key, value);
|
||||
}
|
||||
|
|
@ -232,7 +233,7 @@ class Store {
|
|||
}
|
||||
|
||||
Future<Map<String, dynamic>> getAllItems() async {
|
||||
if (kIsWeb) {
|
||||
if (!PlatformInfos.isMobile) {
|
||||
try {
|
||||
final rawStorage = await getLocalstorage('LocalStorage');
|
||||
return json.decode(rawStorage);
|
||||
|
|
|
|||
9
lib/utils/platform_infos.dart
Normal file
9
lib/utils/platform_infos.dart
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
abstract class PlatformInfos {
|
||||
static bool get isWeb => kIsWeb;
|
||||
static bool get isMobile => !kIsWeb && (Platform.isAndroid || Platform.isIOS);
|
||||
static bool get usesTouchscreen => !isMobile;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue