skip to Main Content

I developed an app in flutter, in this app we are keeping a unique id using UUID package, and I am storing that uuid using shared preferences for guest login purpose.
We tested app on emulator, simulator and 10 to 15 other devices and its working as expected.
but my client has motorola edge 5G UW (2021) phone.
when he tries to use it, he is not able to store that uuid in shared preferences.
as I know for shared preferences there is no permission required and for uuid package as well.
Now I am not sure how to find out that error because my client is not able to install debug apk as well.
Looking for solution, how to find the error that he is getting on his device due to one of these packages, he just gets the grey screen.
Thankyou very much

I am expecting to find out the error, because only clients device throwing that grey screen error.

2

Answers


  1. I highly recommend using Firebase Crashlytics to see what’s happening inside.

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
    
      final FirebaseOptions options = DefaultFirebaseOptions.currentPlatform;
      await Firebase.initializeApp(options: options);
    
      if (kReleaseMode) {
        FlutterError.onError = (FlutterErrorDetails errorDetails) {
          FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails);
        };
        
        PlatformDispatcher.instance.onError = (Object error, StackTrace stack) {
          FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
          return true;
        };
      } else {}
    
      runApp(const MyApp());
    }
    
    

    These few lines of code save precious time and effort. Firebase Crashlytics can see what you cannot see in the release build version.

    Login or Signup to reply.
  2. You can use Firebase Crashlytics as was suggested (also recommend it) or you can use try catch and show the error in a popup/dialog.

    
      Future<void> _storeAndRetrieveUUID() async {
        try {
          // your code
        } catch (e) {
          _showErrorDialog(e.toString());
        }
      }
    
      void _showErrorDialog(String error) {
        showDialog(
          context: context,
          builder: (BuildContext context) {
            return AlertDialog(
              title: Text('Error'),
              content: SingleChildScrollView(
                child: Text(error),
              ),
              actions: [
                TextButton(
                  child: Text('OK'),
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                ),
              ],
            );
          },
        );
      }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search