如何将扑动图表构建到带有脚手架的状态下widget中?
我正在尝试将颤动图表集成到动态应用程序中。我已经根据YouTube教程进行了调整的图表代码,但是我相信原始代码可能是为无状态小部件
而设计的。我正在努力重构代码在statefulwidget
中正确工作,并与脚手架
一起提供整体应用结构。
这是图表代码:
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
class LineTitles {
static GetTitleData() => FlTitlesData(
show: true,
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 35,
getTitlesWidget: (value, meta) {
switch (value.toInt()) {
case 2:
return Text(
'MAR',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
),
);
case 5:
return Text(
'JUN',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
),
);
case 8:
return Text('SEP',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
));
}
return Text(" ");
}),
),
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 35,
getTitlesWidget: (value, meta) {
switch (value.toInt()) {
case 1:
return Text(
'10k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
),
);
case 3:
return Text(
'30k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
),
);
case 5:
return Text('50k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
)
);
}
return Text(" ");
},
)));
}
我正在使用Android Studio
进行开发。有人可以指导如何重组此图表代码以在状态窗口小部件
中有效运行并使用脚手架
在应用程序的布局中?谢谢你!
I'm trying to integrate a Flutter chart into a dynamic app. I have chart code adapted from a YouTube tutorial, but I believe the original code was likely designed for use within a stateless widget
. I'm struggling to refactor the code to work correctly within a StatefulWidget
and alongside a Scaffold
to provide the overall app structure.
Here's the chart code:
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
class LineTitles {
static GetTitleData() => FlTitlesData(
show: true,
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 35,
getTitlesWidget: (value, meta) {
switch (value.toInt()) {
case 2:
return Text(
'MAR',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
),
);
case 5:
return Text(
'JUN',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
),
);
case 8:
return Text('SEP',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16,
));
}
return Text(" ");
}),
),
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 35,
getTitlesWidget: (value, meta) {
switch (value.toInt()) {
case 1:
return Text(
'10k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
),
);
case 3:
return Text(
'30k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
),
);
case 5:
return Text('50k',
style: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 15,
)
);
}
return Text(" ");
},
)));
}
I'm using Android Studio
for development. Can someone guide how to restructure this chart code to function effectively within a stateful widget
and use a Scaffold
for the app's layout? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
干得好。在顶部添加其他缺少的软件包。
Here you go. Add other missing packages in top.