How can I call local Firebase Functions (in Emulator) from Flutter?

前端 未结 1 1905
南旧
南旧 2021-01-26 13:18

I set up Cloud Functions in the local emulator. I wrote a few functions and tested them in the browser with the function emulator. Now I am trying to call these functions from m

相关标签:
1条回答
  • 2021-01-26 13:56

    In steps:

    1. Import the package:

      import 'package:cloud_functions/cloud_functions.dart';
      
    2. Create an instance:

      static final _functions = CloudFunctions.instance;
      
    3. Wire it up to the emulator:

      final origin = Platform.isAndroid ? 'http://10.0.2.2:5001' : 'http://localhost:5001';
      _functions.useFunctionsEmulator(origin: origin);
      

    Also see:

    • Error connecting to local Firebase functions emulator from Flutter app
    • The code for the useFunctionsEmulator function in the Github repo.
    0 讨论(0)
提交回复
热议问题