我当时正在开发一个Flutter项目,一切都工作正常,直到我更新了 My Android Studio和一些SDK 工具。然后,当我尝试运行我的项目时,出现以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at [https://help.gradle.org](https://help.gradle.org)
BUILD FAILED in 1m 4s
Exception: …Run Code Online (Sandbox Code Playgroud) 我目前正在为我的应用程序构建一个验证码屏幕,并使用带有一些 Positioned() 小部件的堆栈,因为验证码表单也应该很好地定位,但如何使其水平居中?
我的代码如下:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Stack(
children: [
Image.asset(verificationImage),
Positioned(
left: MediaQuery.of(context).size.width * 0.075,
top: MediaQuery.of(context).size.height * 0.32,
width: MediaQuery.of(context).size.width * 0.6,
child: Text(
'We have send you an email with a verification code at ${generatedCode[0]}${generatedCode[1]}***',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: MediaQuery.of(context).size.height * 0.025),
),
),
//Later the
// Mail Adress
Positioned(
child: Form(
key: formKey,
child: CodeFields(
length: codeLength,
validator: validateCode,
fieldWidth: MediaQuery.of(context).size.width * 0.1,
fieldHeight: MediaQuery.of(context).size.width * …Run Code Online (Sandbox Code Playgroud) 我知道onLongPress会在一段时间后触发(比如 500 毫秒左右)。但我想做的是当用户按下按钮 3 秒左右时触发一些操作。实际上我想设置 的持续时间onLongPress。
ElevatedButton(
onPressed: () => print('ok I\'m just fine'),
onLongPress: () => print('Trigger me when user presses me for like 3 seconds'),
style: ElevatedButton.styleFrom(
primary: Colors.red,
elevation: 4,
),
Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法检测小部件中发生的溢出并返回一个布尔值以根据trueorfalse值进行一些更改。
例如,我有一个里面有文字的容器。我想检测文本何时溢出容器,之后我将在某些条件下使容器变大。我知道有一些方法,auto_size_text但这里的重点是检测溢出。
我一直在使用RaisedButton直到 Flutter 弃用它,我们不能再使用它了。有一个建议说“ElevatedButton改用”。所以,我想使用它,但我不能看到这样的属性color,elevation,focusColor等。
那么我怎样才能个性化一个ElevatedButton?
在2.0.1flutter版本之前,我使用的是RaisedButton并且有一个属性被调用focusElevation来改变按钮被按下时的高度。因此,在 Flutter 弃用它之后,根据文档,我们应该改用它ElevatedButton。但是现在我找不到用style:属性来改变它的方法。
我知道如何更改高度,但我想更改用户按下时的onPressed 高度。从它的文档来看,它有一些默认值:
按钮的高程是相对于高程参数定义的。禁用的仰角与参数值相同,当按钮悬停或聚焦时使用仰角+2,按下按钮时使用仰角+6。
因此,任何想法如何定制onPressed抬高的ElevatedButton?
每当我尝试使用命令测试我的应用程序时,flutter run它都非常缓慢且缓慢,并且我无法确定我的应用程序在发布模式下的性能如何。然而,为了构建 Android 应用程序,release mode我们需要为应用程序创建一个密钥,它不会显示大部分日志文件和打印。
所以问题是,有没有办法以发布模式格式运行应用程序,但具有调试功能?
我有下面的代码,可以更改用户向下或向上滚动时的工厂不透明度。但为了它,我setState()多次调用该方法。有没有什么方法可以检测用户滚动的最后一个方向,以便我可以setState()在那一刻调用一次?或者,如果您可以为此定义一个新的增强功能,我将不胜感激。
@override
void initState() {
super.initState();
_controller = ScrollController()
..addListener(() {
upDirection = _controller.position.userScrollDirection == ScrollDirection.forward;
upDirection = _controller.position.userScrollDirection == ScrollDirection.reverse;
if (upDirection)
setState(() {
_scrolled = 0.5;
flag = false;
});
else if (!upDirection) {
setState(() {
_scrolled = 1.0;
});
flag = false;
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是清单
return Scaffold(
body:
SingleChildScrollView(
controller: _controller,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(),
Container(),
Container(),
Container(),
Container(),
Container(),
],
),
),
),
floatingActionButton: …Run Code Online (Sandbox Code Playgroud) 我有一个AlertDialog()它barrierDismissible已设置为false。但是,当用户按下 Android 设备上的后退按钮时,AlertDialog 将关闭。如何才能完全阻止用户关闭AlertDialog()?
这是我到目前为止所做的:
return showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Title'),
content: Text('This is the alert dialog content'),
actions: <Widget>[
FlatButton(
child: Text('ok'),
onPressed: () {
Navigator.of(context).pop();
print('ok you win');
},
),
],
);
},
);
Run Code Online (Sandbox Code Playgroud)