我正在创建一个4x3的游戏板。电路板应包含不同的图像。一开始,我只是试图为所有片段加载相同的图像,但是我在应用程序中自行收到一条错误消息:
package com.amazonaws.lambda.demo;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.KinesisEvent;
import com.amazonaws.services.lambda.runtime.events.KinesisEvent.KinesisEventRecord;
public class LambdaFunctionHandler implements RequestHandler<KinesisEvent, Integer> {
@Override
public Integer handleRequest(KinesisEvent event, Context context) {
context.getLogger().log("Input: " + event);
for (KinesisEventRecord rec : event.getRecords()) {
System.out.println(new String(rec.getKinesis().getData().array()));
}
return null;
}
}
答案 0 :(得分:2)
由于Ink.image(image:AssetImage('assets / animals / cat_64_blue.png')),它将生成null GridView构建器错误,
因此,使用Image.asset('assets/animals/cat_64_blue.png'),
代替Ink.image(image: AssetImage('assets/animals/cat_64_blue.png')),
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text("Cat Attack"),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: GridView.builder(
padding: const EdgeInsets.all(10.0),
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4, // 4 columns of board buttons
childAspectRatio: 1.0,
crossAxisSpacing: 9.0,
mainAxisSpacing: 9.0),
itemCount: buttonsList.length,
itemBuilder: (context, i) => new SizedBox(
width: 100.0,
height: 100.0,
child: Material(
elevation: 4.0,
color: Colors.green,
child: Image.asset('assets/animals/cat_64_blue.png'),
),
),
),
),
RaisedButton(
child: new Text(
"Reset",
style: new TextStyle(color: Colors.white, fontSize: 20.0),
),
color: Colors.red,
padding: const EdgeInsets.all(20.0),
onPressed: resetGame,
)
],
));
}
答案 1 :(得分:1)
有2种解决方案。
I。将Ink.image
替换为Image.asset('...'))
II。为child
提供一个Ink.image()
,您只需返回一个Container()
。
Ink.image(
image: AssetImage('assets/animals/cat_64_blue.png'),
child: Container(), // you need this
),