Skip to content

支持带参数的自定义事件 #22

@unclexiao

Description

@unclexiao

目前的自定义事件不支持携带参数:

  static Future<bool> event(String eventId, {String label}) async {
    Map<String, dynamic> map = {
      'eventId': eventId,
    };

    if (label != null) {
      map['label'] = label;
    }

    return _channel.invokeMethod<bool>('event', map);
  }

显然只有一个label是不够的,需要携带更多的Map类型数据。

希望可以扩展这个方法,像友盟官方的这种用法(以安卓平台为例):

Map<String, Object> music = new HashMap<String, Object>();
music.put("music_type", "popular");//自定义参数:音乐类型,值:流行
music.put("singer", "JJ"); //歌手:(林俊杰)JJ
music.put("song_name","A_Thousand_Years_Later"); //歌名:一千年以后
music.put("song_price",100); //价格:100元
MobclickAgent.onEventObject(this, "play_music", music);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions