init method

SilToast init(
  1. GlobalKey<NavigatorState> navigatorKey, {
  2. Color? backgroundColor,
  3. TextStyle? textStyle,
})

Implementation

SilToast init(GlobalKey<NavigatorState> navigatorKey,
    {Color? backgroundColor, TextStyle? textStyle}) {
  _instance.navigatorKey = navigatorKey;

  // 背景颜色
  backgroundColor ??= Color.fromRGBO(0, 0, 0, 0.6);
  _instance.backgroundColor = backgroundColor;

  // 文本样式
  textStyle ??= TextStyle(
      color: Colors.white,
      fontSize: 14,
      fontWeight: FontWeight.normal,
      decoration: TextDecoration.none);
  _instance.textStyle = textStyle;

  return _instance;
}