【发布时间】:2022-01-04 05:04:13
【问题描述】:
我收到以下错误消息:
The body might complete normally, causing 'null' to be returned, but the return type is a potentially non-nullable type.
Try adding either a return or a throw statement at the end.
在尝试使用以下代码使用可观察变量时:
Obx((){ElevatedButton(
child: Text(_authMode.value == AuthMode.Login ? 'LOGIN' : 'SIGN UP'),
onPressed: _submit,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
primary: Theme.of(context).primaryColor,
padding: const EdgeInsets.symmetric(
horizontal: 30.0, vertical: 8.0),
onPrimary: Theme.of(context).primaryTextTheme.button!.color,
))},
),
Obx((){ TextButton(
child: Text(
'${_authMode.value == AuthMode.Login ? 'SIGN UP' : 'LOGIN'} '),
onPressed: _switchAuthMode,
style: TextButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 30.0, vertical: 4),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
textStyle: TextStyle(color: Theme.of(context).primaryColor),
))
}),
不知道怎么解决?
【问题讨论】:
标签: flutter nullable flutter-getx obs