【发布时间】:2022-11-06 03:03:17
【问题描述】:
我使用另一个步进条依赖项(“another_stepper: ^1.0.4”)构建了一个步进条。它运作良好。
像这样...
但我想在这些步骤中添加单独的图像。当我尝试时没有显示。它显示“无法加载”。我无法理解其原因。我在“pubspec.yaml”文件中正确添加了图像
我的代码
@override
State<BarScreen> createState() => _BarScreenState();
}
class _BarScreenState extends State<BarScreen> {
List<StepperData> stepperData = [
StepperData(
title: "Order Placed",
subtitle: "",
),
StepperData(
title: "Preparing",
subtitle: "",
),
StepperData(
title: "On the way",
subtitle: "",
),
StepperData(
title: "Delivered",
subtitle: "",
),
];
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: AnotherStepper(
stepperList: stepperData,
stepperDirection: Axis.vertical,
horizontalStepperHeight: 70,
dotWidget: Container(
padding: const EdgeInsets.all(8),
decoration: const BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.all(Radius.circular(30))),
child: Column(
children: <Widget>[
Row(children: const <Widget>[
Image(
image: AssetImage('assests/logo.png'),
height: 10,
width: 10,
),
]),
Row(children: const <Widget>[
Image(
image: AssetImage('assests/logo.png'),
height: 10,
width: 1,
),
]),
],
)),
activeBarColor: Colors.green,
inActiveBarColor: Colors.grey,
activeIndex: 2,
barThickness: 8,
),
),
),
);
}
}
如何添加单独的图像?
【问题讨论】:
-
您是否在
pubspec.yaml文件中设置了资产路径? -
这个包不支持不同的图标。
-
请显示您的 pubspec 文件资产部分
-
我第一次看到
"Assests"在你的路径中,应该是"assets"。检查 pubspec 是否有正确的缩进。
标签: flutter flutter-layout flutter-dependencies flutter-animation