From 2d6a3c54ffd4652e9c37e02496cf0302d1abab5a Mon Sep 17 00:00:00 2001 From: ludelanier Date: Sat, 25 Nov 2023 20:40:21 +0100 Subject: [PATCH] fix somes issues --- .../components/editable_post_component.dart | 53 +++++++++++++------ Sources/justMUSIC/lib/main.dart | 4 +- Sources/justMUSIC/pubspec.lock | 10 +++- Sources/justMUSIC/pubspec.yaml | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index eb38b8c..221b5ab 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -1,12 +1,16 @@ import 'dart:io'; +import 'dart:html' as html; import 'package:animated_appear/animated_appear.dart'; import 'package:auto_size_text/auto_size_text.dart'; +import 'package:firebase_storage/firebase_storage.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:insta_image_viewer/insta_image_viewer.dart'; import 'package:justmusic/values/constants.dart'; import 'package:text_scroll/text_scroll.dart'; @@ -60,18 +64,34 @@ class _EditablePostComponentState extends State with Tick } Future pickImage(ImageSource source) async { - try { - - final image = await ImagePicker().pickImage(source: source, imageQuality: 20); - if (image == null) return; - final imageTemp = File(image.path); - setState(() { - this.image = imageTemp; - widget.callBackImage(imageTemp); - }); - } on PlatformException catch (e) { - print('Failed to pick image: $e'); + if(kIsWeb){ + print('you are on web'); + try { + final image = await ImagePicker().pickImage(source: source, imageQuality: 20); + if (image == null) return; + final imageTemp = File(image.path); + setState(() { + this.image = imageTemp; + widget.callBackImage(imageTemp); + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } } + else{ + try { + final image = await ImagePicker().pickImage(source: source, imageQuality: 20); + if (image == null) return; + final imageTemp = File(image.path); + setState(() { + this.image = imageTemp; + widget.callBackImage(imageTemp); + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + } void _updateDescription(String text) { @@ -182,7 +202,10 @@ class _EditablePostComponentState extends State with Tick borderRadius: BorderRadius.circular(20), child: InstaImageViewer( backgroundIsTransparent: true, - child: Image( + child: kIsWeb?InstaImageViewer( + backgroundIsTransparent: true, + child: Image.network(image!.path) + ):Image( image: FileImage(image!), fit: BoxFit.cover, ), @@ -250,8 +273,8 @@ class _EditablePostComponentState extends State with Tick width: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( + children: [ kIsWeb?Container() + :Expanded( flex: 5, child: GestureDetector( onTap: () { @@ -262,7 +285,7 @@ class _EditablePostComponentState extends State with Tick ), ), ), - SizedBox( + kIsWeb?Container():SizedBox( width: 15, ), Expanded( diff --git a/Sources/justMUSIC/lib/main.dart b/Sources/justMUSIC/lib/main.dart index 7c1d49e..bd974fd 100644 --- a/Sources/justMUSIC/lib/main.dart +++ b/Sources/justMUSIC/lib/main.dart @@ -80,9 +80,7 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); - Paint.enableDithering = true; - - FullScreenWindow.setFullScreen(true); // enter fullscreen + Paint.enableDithering = true; // enter fullscreen return ScreenUtilInit( useInheritedMediaQuery: true, diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index cfef692..7cfaca7 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -745,7 +745,7 @@ packages: source: hosted version: "0.8.7+4" image_picker_for_web: - dependency: "direct main" + dependency: transitive description: name: image_picker_for_web sha256: "50bc9ae6a77eea3a8b11af5eb6c661eeb858fdd2f734c2a4fd17086922347ef7" @@ -784,6 +784,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.9.0" + image_picker_web: + dependency: "direct main" + description: + name: image_picker_web + sha256: e1656f1ce48a614aefdf22ab73c0cc7e498fa7b78893ffdcc83171e7289092e0 + url: "https://pub.dev" + source: hosted + version: "3.1.1" image_picker_windows: dependency: transitive description: diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index c0bd0f0..c5832f4 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -78,7 +78,7 @@ dependencies: google_sign_in: ^6.1.4 flutter_launcher_icons: ^0.13.1 fullscreen_window: ^1.0.3 - image_picker_for_web: ^3.0.1 + image_picker_web: ^3.1.1 dev_dependencies: flutter_test: