# 快速入门

# 引入头文件

在需要使用文档编辑器的页面中引入IFLYDOC FLutter SDK的头文件。

import 'package:iflydocs_flutter_plugin/iflydocs_sdk_flutter.dart';

# 创建视图Widget

设置GlobalKey,以方便操控编辑器回调。

final GlobalKey<IFLYDocsEditorViewState> editorKey = GlobalKey();

创建编辑器视图Widget在对应视图中,并设置GlobalKey与回调方法

child:IFLYDocsEditorView(
              key: editorKey,
              editorCallBack:editorCallBack,
            )

创建回调方法

void editorCallBack(String method, Map arguments) {
    print('************** ${method} ${arguments}');
    switch(method) {
      case "docsOnEditorLoad":
        // 编辑器加载完毕,激活协作
        editorKey.currentState.activeCollaboration("10EX", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjIjoiN2U2ZTgwMzUiLCJzIjoxNjM2MzQ3MDc2NTQwLCJ0IjoiQSIsInUiOiIxNjI4MjM1NjI2NDU4IiwiaXNzIjoiYXV0aDAiLCJleHAiOjE2MzY0MzM0NzZ9.Z7oJyiuT6tKjeb1X4QIKzDiV6eGJ4-4_JDo8VZCs2Xc", "wss://devopenapi.iflydocs.com", "", "", "");
        break;
      case "docsOnContentReady":
        break;
      case "onFormatChangeWithFormatInfo":
        break;
      default:
        throw UnsupportedError("Unrecognized method");
    }
  }