crazecoder / flutter_bugly

腾讯Bugly flutter应用更新统计及异常上报插件,支持Android、iOS
Other
595 stars 163 forks source link

FlutterBugly.init初始化报错:functions must have an explicit list of parameters try adding a parameter list #88

Closed zhaobinglong closed 4 years ago

zhaobinglong commented 4 years ago
import 'package:flutter_bugly/flutter_bugly.dart';

//使用flutter异常上报
void main()=>FlutterBugly.postCatchedException((){
  runApp(MyApp());
});

FlutterBugly.init(androidAppId: "your android app id",iOSAppId: "your iOS app id");

参考博客这样的写法后报错:functions must have an explicit list of parameters try adding a parameter list

解决办法: FlutterBugly.init方法需要写在MyApp()下面第一个页面的initState()生命周期中,不能直接写在main文件中

  @override
  void initState() {
    super.initState();
    FlutterBugly.init(
      androidAppId: "your android id",
      iOSAppId: "your app id",
    ).then((_result) {
      // do something
    });
  }

参考:https://github.com/crazecoder/flutter_bugly/blob/master/example/lib/main.dart