我正在使用步进器小部件来从用户那里收集信息并对其进行验证,我需要在每一步调用一个 API,因此在每个继续按钮的步骤中验证每个字段......我正在使用表单状态和表单小部件但问题是它在步进器的所有步骤中验证整个字段......我如何仅验证步进器中的单个步骤?我浏览了 stepper.dart 中的 Stepper 和 State 类中的文档,但那里没有支持功能
以下是代码
class SubmitPayment extends StatefulWidget {
SubmitPayment({Key key, this.identifier, this.amount, this.onResendPressed})
: super(key: key);
final String identifier;
final String amount;
final VoidCallback onResendPressed;
@override
State<StatefulWidget> createState() {
return _SubmitPaymentState();
}
}
class _SubmitPaymentState extends State<SubmitPayment> {
final GlobalKey<FormState> _formKeyOtp = GlobalKey<FormState>();
final FocusNode _otpFocusNode = FocusNode();
final TextEditingController _otpController = TextEditingController();
bool _isOTPRequired = false;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Form(
key: _formKeyOtp,
child: Column(children: …Run Code Online (Sandbox Code Playgroud) 我的 flutter 应用程序具有对阿拉伯语的 RTL(本地化)支持。我有一个颤动的屏幕,它在一个列小部件内有一个 GridView 小部件。以下是截图
当语言是英语时:
当语言切换为阿拉伯语时
我的代码是:
class TransactionSummary extends StatelessWidget {
final String name;
final String settlementDate;
final int transactionCount;
final String credit;
final String debit;
final String discount;
TransactionSummary(
{this.name,
this.settlementDate,
this.transactionCount,
this.credit,
this.debit,
this.discount});
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextTheme textTheme = theme.textTheme.copyWith(
title: theme.textTheme.title.copyWith(
fontSize: 18.0,
color: kMaximusBlue900,
fontWeight: FontWeight.w600),
subhead: theme.textTheme.subhead
.copyWith(color: Colors.black, fontSize: 16.0),
caption: theme.textTheme.caption
.copyWith(color: theme.hintColor, fontSize: 14.0));
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ …Run Code Online (Sandbox Code Playgroud) 我有一个静态列表:
public static List<IMachines>mList =new List<IMachines>();
Run Code Online (Sandbox Code Playgroud)
该列表中包含两种不同类型的对象(机器):
IMachines machine = new AC();
IMachines machine = new Generator();
Run Code Online (Sandbox Code Playgroud)
如果在向列表中添加项目后,我想通过其name属性搜索特定的机器,然后在使用foreach循环进行遍历后,如果在列表中找到该项目...我该如何知道该项目是否为AC类型还是Generator打字?
我正在尝试为我的数据表中的每一行运行循环但它给我错误,因为我无法修改每个循环的集合...我还能做些什么来更新表?
我正在尝试删除作为设备名称的单个列的重复条目,如果根据重复的设备名称进行此类选择,则只需更新旧数量.
这是代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt = new DataTable();
dt.Columns.Add("Appliance Name", typeof(string));
dt.Columns.Add("Quantity", typeof(int));
dt.Columns.Add("Day Time(Hrs)", typeof(int));
dt.Columns.Add("Backup Time(Hrs)", typeof(int));
// dt.Rows.Add("Sana", 5, 4, 3);
Session["MyDataTable"] = dt;
}
}
protected void BtnAddNext_Click(object sender, EventArgs e)
{
DataTable dtab = (DataTable)Session["MyDataTable"];
if (dtab.Rows.Count != 0)
{
foreach (DataRow r in dtab.Rows)
{
if (Convert.ToString(r["Appliance Name"]) == DDLAppName.Text)
{
int temp = Convert.ToInt32(r["Quantity"]);
r["Quantity"] = Convert.ToInt32(QtyTB.Text) + temp;
} …Run Code Online (Sandbox Code Playgroud) 您好,我正在关注微软文档...
为了在 .NET Core Web API 中将配置作为单例注入
这是我加载配置的Program.cs代码:
public class Program
{
public static Dictionary<string, string> arrayDict =
new Dictionary<string, string>
{
{"connString", "Data Source =xxx/xxx;User Id =xxx;Password =xxx"}
};
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(builder =>
{
builder.AddInMemoryCollection(arrayDict);
builder.AddJsonFile(
"appsettings.json", optional: false, reloadOnChange: false);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
Run Code Online (Sandbox Code Playgroud)
在Startup.cs中我使用以下内容
public class Startup
{
private readonly IConfiguration Configuration;
public Startup(IConfiguration config)
{
Configuration = …Run Code Online (Sandbox Code Playgroud) c# dependency-injection .net-core asp.net-core asp.net-core-webapi