【发布时间】:2021-12-08 15:44:48
【问题描述】:
这个问题的原因是什么? 当我点击按钮显示 toast 时,会出现此消息
在处理手势时引发以下 _CastError: 用于空值的空检查运算符
*当异常被抛出时,这是堆栈: showToastWidget(包:flutter_styled_toast/src/styled_toast.dart:268:22)
home: Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {
showToast(txt,
context: context,
animation: StyledToastAnimation.slideFromLeft,
reverseAnimation: StyledToastAnimation.slideToBottom,
position: StyledToastPosition(
align: Alignment.bottomCenter, offset: 55),
animDuration: Duration(milliseconds: 300),
duration: Duration(seconds: 2),
curve: Curves.easeInOutBack,
reverseCurve: Curves.elasticIn,
backgroundColor: Color.fromRGBO(191, 21, 35, 0.5),
textStyle: TextStyle(fontSize: 20, color: Colors.white));
},
child: const Icon(Icons.add),
),
appBar: AppBar(title: Text('Flutter Code Sample')),
body: const Center(
child: MyStatelessWidget(),
),
),
);
}
}
【问题讨论】:
-
你能不能把home
Scaffold分开在不同的widget上再试一次。 -
什么是
txt?你能发一个minimal reproducible example吗? -
谢谢,已经解决@YeasinSheikh
-
@nvoigt
txt在图片中 -
你可以阅读它here