Flutter是一个相当新的框架,因此在简单任务上没有太多帮助。我要特别问的是如何将Card小部件添加到Column小部件中。下面提供了源代码,以帮助解释我的意思。
可以说我有一个创建新卡的功能,如下所示:
buildRow(barcode, letter, name, price) {
return new Card(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new ListTile(
leading: new CircleAvatar(
child: new Text(letter),
),
title: new Text(name),
subtitle: new Text("\$" + price),
trailing: new Text(
"x1",
style: new TextStyle(color: Colors.lightBlue),
textScaleFactor: 1.2,
),
),
],
),
);
}
var snack = buildRow("091918229292", "C", "Crackers", "\$4.00");
var fruit = buildRow("091928229292", "P", "Pomegranate", "\$2.00");
var juice = buildRow("091948229292", "K", "Kiwi Juice", "\$20.00");
Run Code Online (Sandbox Code Playgroud)
而且我有以下屏幕/页面:
class Home extends StatefulWidget {
@override
HomePage …Run Code Online (Sandbox Code Playgroud) 我无法弄清楚这个程序有什么问题.我试过用
strncpy(text,array[ ],sizeof(text))
Run Code Online (Sandbox Code Playgroud)
已经但是没有解决任何问题.我需要的是一种复制字符串的简单方法,如pascal语言,其中可以使用简单的等号来复制字符串(或者可以执行此操作的生成函数).这是源代码:
#include <stdio.h>
#include <string.h>
int x,y;
char array[10][10];
int choice;
char text[5];
int main()
{
for(x=0;x<5;x++)
{
printf("ENTER text: ");
scanf("%s", text);
strcpy (text,array[x]);
}
for (y=0;y<5;y++)
{
printf("\n");
printf("%s", array[y]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出应该是这样的;
"*string*"
"*string*"
"*string*"
"*string*"
"*string*"
Run Code Online (Sandbox Code Playgroud)
但我得到的是五个空格,没有字符串.任何方案?