gpt4 book ai didi

flutter - 右侧带有 labelText 的 TextField

转载 作者:行者123 更新时间:2023-12-04 14:30:49 25 4
gpt4 key购买 nike

我试图将 TextField 的标签放在右侧,但我不知道如何。
文字没问题,但问题出在标签上。

          TextField(
enabled: this.enable,
enableInteractiveSelection: false,
autofocus: false,
textAlign: TextAlign.right,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: this.label,
hintText: this.hint,
alignLabelWithHint: true,
errorText: snapshot.hasError ? snapshot.error : null),
obscureText: this.obscure,
controller: _controller,
);

有人可以帮助我如何将 labelText 也放在右侧吗?

最佳答案

您可以使用 Directionality .

enter image description here

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MyHomePageState();
}
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: EdgeInsets.all(30),
child: Directionality(
textDirection: TextDirection.rtl,
child: TextField(
textAlign: TextAlign.right,
autofocus: true,
decoration: new InputDecoration(
border: OutlineInputBorder(),
labelText: "ایمیل",
hintText: "ایمیل خود را وارد کنید"
),
)
)
),
)
);
}
}

关于flutter - 右侧带有 labelText 的 TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58735933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com