#arrays #list #flutter #button
Вопрос:
Я использую этот код для управления изображением и текстом, каждый раз, когда я нажимаю кнопку, он правильно изменяет мою личность, но не обновляет изображение и имя.
Что я делаю не так? Я объявляю имя с [i], полагая, что оно заряжается, но оно не появится. переключение с одного идентификатора на другой работает правильно, только я хотел бы, чтобы имя и изображение также обновлялись
return Container(
height: Get.height,
child: Obx(
() => Column(
children: [
Expanded(
flex: 0,
child: Builder(builder: (context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
flex: 2,
child: Builder(builder: (context) {
final List<int> id = [
ContentBloc().state.userInfo.id,
...ContentBloc()
.state
.connectedUnits()
.map((e) => e.id),
];
for (int i = 0; i < id.length; i ) {
final List<String> name = [
// ignore: lines_longer_than_80_chars
"${ContentBloc().state.userInfo.firstName} ${ContentBloc().state.userInfo.lastName}",
...ContentBloc()
.state
.connectedUnits()
.map((e) => e.storeName)
];
final children = [
IconButton(
onPressed: (_identityController.value !=
ContentBloc()
.state
.userInfo
.id) amp;amp;
(_identityController.value > 0)
? () => _identityController.call(id[i])
: null,
icon: const Icon(
Icons.arrow_back_ios_rounded,
),
),
Padding(
padding: const EdgeInsets.only(top: 18),
child: Column(
children: [
ProfilePicture(
key: ValueKey(id[i].toString()),
size: 100,
id: id[i].toString(),
isUnit: false,
showIcon: false,
),
Padding(
padding:
const EdgeInsets.only(top: 18),
child: Text(
name[i],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 19,
fontWeight: Fonts.medium,
),
),
),
],
),
),
IconButton(
onPressed: _currentIndex.value < id.length
? () =>
_identityController.call(id[i 1])
: null,
icon: const Icon(
Icons.arrow_forward_ios_rounded,
),
),
];
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: children,
);
}
return Container();