我有一个稳定的颤振通道 SDK,位于 c:\flutter。它在系统环境变量中设置为 Flutter 的默认路径。
在 IntelliJ 中为我们的客户创建新的 Flutter 项目时,我正在使用此路径 c:\flutter。
我还在 c:\flutter_master 下载了 Flutter master channel,我需要将这个 flutter SDK (master) 用于另一个项目。
如何在同一设备上为不同项目正确使用两个工作 Flutter 版本而无需每次都使用系统环境变量?
我如何检索flutter app的当前字体系列名称,默认值是什么?
我试过了
Theme.of(context).textTheme.
Run Code Online (Sandbox Code Playgroud)
和
Theme.of(context).
Run Code Online (Sandbox Code Playgroud)
但是字体系列没有属性.
我的内容很长,当用户进入我的页面时,默认情况下需要显示滚动条。
当前,直到用户单击文本,才显示这些条,这不是很好的行为,因为用户可以离开页面而不会注意到有一些未读文本。
我的代码:
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(15.0),
child: Center(
child: Column(
children: <Widget>[
Image.asset(
"assets/images/logo.png",
height: 200.0,
),
SizedBox(
height: 40,
),
Expanded(
child: Scrollbar(
child: SingleChildScrollView(
child: Text("Long Text Here ...",
textDirection: TextDirection.rtl,
style: TextStyle(fontSize: 17.2),
),
),
),
),
SizedBox(
height: 50,
),
Row(
children: <Widget>[
Expanded(
child: RaisedButton(
child: Text("Continue"),
onPressed: () {
MaterialPageRoute route = MaterialPageRoute(
builder: (BuildContext context) => MainPage());
Navigator.of(context).push(route);
},
),
),
SizedBox(
width: 20.0,
),
RaisedButton(
child: Text("Close"),
onPressed: …Run Code Online (Sandbox Code Playgroud) 如何在flutter应用程序中显示阿拉伯格式的数字?
\n\n我需要将它们显示为 \xd9\xa1、\xd9\xa2、\xd9\xa3,而不是将数字显示为 1,2,3
\n\n我尝试使用 NumberFormat 类,但它不起作用。
\n\n颤振医生:
\n\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x88\x9a] Flutter (Channel dev, v0.8.2, on Microsoft Windows [Version 10.0.17134.345], locale ar-SA)\n[\xe2\x88\x9a] Android toolchain - develop for Android devices (Android SDK 28.0.2)\n[\xe2\x88\x9a] Android Studio (version 3.1)\n[\xe2\x88\x9a] IntelliJ IDEA Community Edition (version 2018.2)\n[!] VS Code, 64-bit edition (version 1.27.2)\n[\xe2\x88\x9a] Connected devices (2 available)\n\n! Doctor found issues in 1 category.\nRun Code Online (Sandbox Code Playgroud)\n\n例子:
\n\nimport \'package:flutter/material.dart\';\nimport \'package:flutter/widgets.dart\';\n\nimport \'package:intl/intl.dart\';\n\nvoid main() => runApp(new MyApp());\n\nclass …Run Code Online (Sandbox Code Playgroud) 构建我的无状态窗口小部件时,我使用以下代码按顺序播放一些声音:
await _audioPlayer.play(contentPath1, isLocal: true);
await Future.delayed(Duration(seconds: 4));
await _audioPlayer.play(contentPath2, isLocal: true);
await Future.delayed(Duration(seconds: 4));
await _audioPlayer.play(contentPath3, isLocal: true);
Run Code Online (Sandbox Code Playgroud)
当用户在结束播放声音之前关闭当前小部件时,即使使用以下代码关闭了当前路线,声音仍然起作用:
Navigator.pop(context);
Run Code Online (Sandbox Code Playgroud)
我的解决方法是使用布尔变量来指示关闭操作是否完成。
播放声音代码:
await _audioPlayer.play(contentPath1, isLocal: true);
if (closed) return;
await Future.delayed(Duration(seconds: 4));
if (closed) return;
await _audioPlayer.play(contentPath2, isLocal: true);
if (closed) return;
await Future.delayed(Duration(seconds: 4));
if (closed) return;
await _audioPlayer.play(contentPath3, isLocal: true);
Run Code Online (Sandbox Code Playgroud)
关闭当前小部件:
closed = true;
_audioPlayer.stop();
Run Code Online (Sandbox Code Playgroud)
如果我的小部件已关闭,是否有更好的方法来停止异步方法?
如何检查 Flutter 中是否存在特定资产。我正在尝试加载一些图像和声音文件,并且需要处理这些资产不存在的情况。
我需要检查是否存在,因为我有从 1 到 1000 的数字的音频文件和图像。当我构建小部件时,我使用从 1 到 1000 的循环来构建它。并且有可能资源中不存在所需的文件(当前号码的图像或声音)。
首先,我不会像这样在 MaterialApp 中设置路线
new MaterialApp(
home: new Screen1(),
routes: <String, WidgetBuilder> {
'/screen1': (BuildContext context) => new Screen1(),
'/screen2' : (BuildContext context) => new Screen2(),
'/screen3' : (BuildContext context) => new Screen3(),
'/screen4' : (BuildContext context) => new Screen4()
},
)
Run Code Online (Sandbox Code Playgroud)
相反,我通过像这样推送新路由来从我的应用程序中的不同位置路由:
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
Screen3(someInputData)));
Run Code Online (Sandbox Code Playgroud)
例如,如何将屏幕从当前屏幕弹出到屏幕编号 2?