Search code examples
fluttersqfliteflutter-packages

Already using sqflite database for mobile App which is not supporting to WebApp,can i use different library for web App in same if yes than which lib


i am using sqflite library for database but it is supporting to IOS/Android app can i use to database for App existing one(Sqflite) and for webApp different in the same app if I can then how and which will be the best.Thanks


Solution

  • Yes. You can use a separate package for the web. Now, to check whether your app is running on web or not:

    import 'package:flutter/foundation.dart' show kIsWeb;
    
    if (kIsWeb) {
      // running on the web!
    } else {
      // NOT running on the web! You can check for additional platforms here.
    }
    

    If your use-case is just to store small values, you can use shared_preferences which is supported for both web and mobile.

    You can also try hive which is supported for both.