| // Copyright 2013 The Flutter Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| package com.example.espresso; |
| |
| import androidx.annotation.NonNull; |
| import io.flutter.embedding.engine.plugins.FlutterPlugin; |
| import io.flutter.plugin.common.MethodCall; |
| import io.flutter.plugin.common.MethodChannel; |
| import io.flutter.plugin.common.MethodChannel.MethodCallHandler; |
| import io.flutter.plugin.common.MethodChannel.Result; |
| |
| /** EspressoPlugin */ |
| public class EspressoPlugin implements FlutterPlugin, MethodCallHandler { |
| @Override |
| public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { |
| final MethodChannel channel = |
| new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "espresso"); |
| channel.setMethodCallHandler(new EspressoPlugin()); |
| } |
| |
| // This static function is optional and equivalent to onAttachedToEngine. It supports the old |
| // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting |
| // plugin registration via this function while apps migrate to use the new Android APIs |
| // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. |
| // |
| // It is encouraged to share logic between onAttachedToEngine and registerWith to keep |
| // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called |
| // depending on the user's project. onAttachedToEngine or registerWith must both be defined |
| // in the same class. |
| @SuppressWarnings("deprecation") |
| public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) { |
| final MethodChannel channel = new MethodChannel(registrar.messenger(), "espresso"); |
| channel.setMethodCallHandler(new EspressoPlugin()); |
| } |
| |
| @Override |
| public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { |
| if (call.method.equals("getPlatformVersion")) { |
| result.success("Android " + android.os.Build.VERSION.RELEASE); |
| } else { |
| result.notImplemented(); |
| } |
| } |
| |
| @Override |
| public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} |
| } |