atsign-foundation / at_widgets

Flutter widgets which aid in building applications using Atsign's technology
https://docs.atsign.com
BSD 3-Clause "New" or "Revised" License
53 stars 32 forks source link

packages depending on fluttertoast are being a blocker for the apps/widgets which use file_picker/image_picker in iOS #443

Open yahu1031 opened 2 years ago

yahu1031 commented 2 years ago

Which at_widget package you find issue with?

at_location_flutter

On what platforms did you experience the issue?

iOS

What version are you using?

at_location_flutter: ^3.1.6

What happened?

Because of the fluttertoast used in at_location_flutter, we cannot pick any file from iCloud. Either the fluttertoast can be a direct dependency or a transitive dependency the issue exists. I have raised a ticket regarding this issue. https://github.com/miguelpruivo/flutter_file_picker/issues/1003, https://github.com/flutter/flutter/issues/105919

Steps to reproduce

  1. Create an at_app.
  2. Add at_location_flutter package.
  3. Add any file upload/file picking functionality.
  4. Run flutter pub get and cd ios && pod install.
  5. Run flutter run

Additional info

fluttertoast is the culprit. Happened in the new Buzz application.

Relevant log output

Launching lib/main.dart on iPhone 13 in debug mode...
Xcode build done.                                           42.8s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-07-05 14:03:52.884 xcodebuild[70039:1351108] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-07-05 14:03:52.884 xcodebuild[70039:1351108] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **
Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/pc/8zz9zy_d5jxctzt7xq13z6740000gn/T/flutter_tools.RzbbZx/flutter_ios_build_temp_dirKj7Uvl/temporary_xcresult_bundle
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:39:52: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDataSource: class {
                                                       ^~~~~
                                                       AnyObject
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:55:50: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDelegate: class {
                                                     ^~~~~
                                                     AnyObject
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:39:52: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDataSource: class {
                                                       ^~~~~
                                                       AnyObject
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:55:50: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDelegate: class {
                                                     ^~~~~
                                                     AnyObject
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:39:52: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDataSource: class {
                                                       ^~~~~
                                                       AnyObject
    /Users/minnu/Desktop/buzz/ios/Pods/DKPhotoGallery/DKPhotoGallery/DKPhotoGalleryContentVC.swift:55:50: warning: using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead
    internal protocol DKPhotoGalleryContentDelegate: class {
                                                     ^~~~~
                                                     AnyObject
    /Users/minnu/Desktop/buzz/ios/Runner/GeneratedPluginRegistrant.m:72:9: fatal error: module 'fluttertoast' not found
    @import fluttertoast;
     ~~~~~~~^~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/minnu/Desktop/buzz/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target 'Toast' from project 'Pods')
    /Users/minnu/Desktop/buzz/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FMDB' from project 'Pods')
    Result bundle written to path:
        /var/folders/pc/8zz9zy_d5jxctzt7xq13z6740000gn/T/flutter_tools.RzbbZx/flutter_ios_build_temp_dirKj7Uvl/temporary_xcresult_bundle
Parse Issue (Xcode): Module 'fluttertoast' not found
/Users/minnu/Desktop/buzz/ios/Runner/GeneratedPluginRegistrant.m:71:8
Could not build the application for the simulator.
Error launching application on iPhone 13.
Exited

Flutter analyze output

No response

Flutter doctor output

No response

yahu1031 commented 2 years ago

Solution I propose

Make use of ScaffoldMessenger and make custom toasts.

Additional Info

I see them in

gkc commented 2 years ago

I see you raised an issue on the fluttertoast repo. Let's wait to hear back from the fluttertoast maintainer if they can resolve the issue. Alternatively, if you know how to resolve the issue, you could do the fix and test it and submit a PR to FlutterToast

yahu1031 commented 2 years ago

@gkc Yes, I did raise it in the rest of the repos that were being blocked by this package. Sadly I don't know the solution cause no traces were being found. So need to wait. And also this is a blocker for all the apps that use the above packages I mentioned. They can't move forward. They will get stuck on onboarding itself. I will wait for it and need to be discussed what to do in this scenario. Thanks.

gkc commented 2 years ago

What's latest on this @yahu1031 ?

yahu1031 commented 2 years ago

@gkc Currently, no work is seen on that ticket. And also no activity was found. There was a solution that needs to be done from our side. That is, Remove the fluttertoast from the packages and create our own custom toasts with ScaffoldMessanger. We can create a package and use it.

ksanty commented 2 years ago

@yahu1031 I'm reassigning priority to high, so we can add to PR43 or PR44

yahu1031 commented 2 years ago

@sonle-geekyants @sachins-geekyants @nitesh2599 Any idea or updates?

yahu1031 commented 2 years ago
void showToast(BuildContext? context, String msg,
        {double? width, bool isError = false}) =>
    ScaffoldMessenger.of(context!).showSnackBar(
      SnackBar(
        content: Text(
          msg,
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 12,
            color: isError ? Colors.white : Colors.black,
          ),
        ),
        duration: const Duration(milliseconds: 3000),
        elevation: 0,
        margin: width != null
            ? null
            : EdgeInsets.symmetric(
                horizontal: MediaQuery.of(context).size.width * 0.2),
        backgroundColor: isError
            ? Colors.red[700]
            : Colors.white,
        padding: const EdgeInsets.all(10),
        width: width,
        behavior: SnackBarBehavior.floating,
        shape: RoundedRectangleBorder(
          borderRadius: Platform.isAndroid
              ? BorderRadius.circular(50)
              : BorderRadius.circular(10),
        ),
      ),
    );

This code block will show the toast same as now. So we can get rid of flutter toast package. LMK what do you think.

sachins-geekyants commented 2 years ago

@yahu1031 Are we replacing toast message with snackbar ?

yahu1031 commented 2 years ago

May be. I suggest to do so.

sachins-geekyants commented 2 years ago

@Pritam-deb please test this branch by Minnu : https://github.com/atsign-foundation/at_widgets/tree/toast_fix

Where flutter toast is replaced by snackbar.

yahu1031 commented 2 years ago

Moving this ticket requires validation

Pritam-deb commented 2 years ago

The text can be a bit bigger. The toast could also pop a bit higher.

sachins-geekyants commented 2 years ago

@Pritam-deb can you share screenshots of both the UI? it will be easier to compare.

yahu1031 commented 2 years ago

@Pritam-deb Toast has fontSize and gravity properties now.

Pritam-deb commented 2 years ago

minnu customToast.webm This is branch on which @yahu1031 worked in. flutterToast.webm Here, I have used FlutterToast here

Hence, looks good enough.

yahu1031 commented 2 years ago

@Pritam-deb This issue from the fluttertoast seems fixed, Cross check this with fluttertoast package, If it works, use it. https://github.com/ponnamkarthik/FlutterToast/issues/391#event-7594635351