我找不到在 Flutter 中创建协议的方法。它们是否存在或是否有其他替代方式?
class X extends Y {
X(int a, int b) : super(a,b);
}
Run Code Online (Sandbox Code Playgroud)
有人能给我解释一下冒号的语法含义:吗?
我想在右上角输入一个我想要圆形的图像描述。我试过对齐,但没有奏效。有什么建议吗?
这是我到目前为止所做的:
import 'package:flutter/material.dart';
class Login extends StatefulWidget {
@override
_LoginState createState() => _LoginState();
}
class _LoginState extends State<Login> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Login"),),
body: CircleImage(),
);
}
}
class CircleImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
child: Image.asset("images/login_img.png", alignment: Alignment(1.0, 1.0),),
clipper: CircleClipper(),
);
}
}
class CircleClipper extends CustomClipper<Path>{
@override
getClip(Size size) {
var path = Path();
path.addOval(new Rect.fromCircle(center: new Offset(size.width/2, size.height/2), radius: size.width …Run Code Online (Sandbox Code Playgroud) 是否有一些函数可以将请求参数添加到 http 请求中,而您不必“手动”执行此操作?例如,如果我想"user": "x"作为我的请求的参数,以某种方式实现类似
http:test/testing?user=x
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
如果我读到只有当您想要做的不仅仅是检索这些值时,才必须在 Dart 中明确开发 setter 和 getter。但是如果我有私有变量,比如:
Class User {
User _user;
String _password;
}
Run Code Online (Sandbox Code Playgroud)
如何访问这些私有变量?即使我实现了设置的密码
set password(String value) => _password = value;
Run Code Online (Sandbox Code Playgroud)
它当然会给我一个“错误”。
我有一个整数列表,例如:
List<int> list = [1,2,3,4,5];
Run Code Online (Sandbox Code Playgroud)
我想在文本小部件中显示此列表,其结果是:1、2、3、4、5
相反,发生的是它向我显示了括号内的数字:(1,2,3,4,5)
这是我的代码:
final String textToDisplay = list.map((value) {
String numbers = '';
return numbers + value.toString() + ',';
}).toString()
Run Code Online (Sandbox Code Playgroud)
然后在小部件中:
Text(textToDisplay);
Run Code Online (Sandbox Code Playgroud) 我正在使用 vuejs 3 和 TS。
我在 TS 中创建了这样的翻译文件:
索引.ts:
export default {
'example': 'example',
}
Run Code Online (Sandbox Code Playgroud)
然后为了以这种方式使用它:
{{ $t('example') }}
Run Code Online (Sandbox Code Playgroud)
现在我想将参数传递给翻译,例如:
索引.ts:
export default {
'hi_man': 'Hi {name}', //where the name is the parameter
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我想要一些 FormTextFields,其中包含一些用户可以更改的默认文本。我的问题是,一旦我修改了一个字段,如果我按下另一个字段或按钮,一切都很好,但是,如果我按下键盘上的“完成”按钮,则返回默认文本,删除用户插入的新的。这是我到目前为止所做的:
class _LoginSettingsViewState extends State<LoginSettingsView> {
final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
var _userTextController = new TextEditingController();
@override
Widget build(BuildContext context) {
_userTextController.text = "test";
return Scaffold(
appBar: AppBar(
title: Text("Settings"),
),
body: ListView(
children: <Widget>[
new Container(
margin: EdgeInsets.only(
left: 10.0,
right: 10.0,
top: MediaQuery.of(context).size.height / 10
),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
decoration: _fieldDecoration("user", null),
controller: _userTextController,
validator: (val) => val.isEmpty ? "Insert user" : null,
onSaved: (val){
print(val);
},
),
Run Code Online (Sandbox Code Playgroud) 我如何测试它是否应该找到像 Icons.visibility 这样的特定图标?这是我的测试:
testWidgets(
'Should find visibility_off icon',
(WidgetTester tester) async {
await _buildApp(tester);
await tester.pumpAndSettle();
expect(find.byWidget(Icon(Icons.visibility)), findsOneWidget);
});
Run Code Online (Sandbox Code Playgroud)