in my case i have stateFulwidget that will handle move,rotate and scale of widget i have map<String,Widget> ... after move or action in screen i will update the stateFulwidget as set new info's on that what is the problem list Widgets from Map working fine until i just creating and adding stateFulwidget into List but if i want to remove or update the stateFullWidget in List will not work
im confused! i dont know why and what is the problem in case please help and give me some idea for resolve this Thank you
the provider Class
class ProviderStoryCustomText with ChangeNotifier {
Map<String, Map<String, dynamic>> textsMapInfo = {};
Map<String, Widget> listWidgets = {};
void setTextInfo({
required List<Color> screenColorsList,
required double screenWidth,
required String textID,
required String text,
required Color color,
required Color backGroundColor,
required int backGroundStatus,
required int alignStatus,
required String? fontFamily,
required int? fontSelectedIndex,
required double? positionY,
required double? positionL,
required double rotate,
required double scale,
}) {
String iD = DateTime.now().millisecondsSinceEpoch.toString();
textsMapInfo[iD] = {
'textID': iD,
'text': text,
'color': color,
'backGroundColor': backGroundColor,
'textBackGroundStatus': backGroundStatus,
'alignStatus': alignStatus,
'fontFamily': fontFamily,
'fontSelectedIndex': fontSelectedIndex,
'positionY': positionY,
'positionL': positionL,
'rotate': rotate,
'scale': scale,
};
add(textID, iD, screenWidth, screenColorsList);
}
void add(String textID, String iD, double screenWidth,
List<Color> screenColorsList) {
// listWidgets = {};
if (listWidgets.containsKey(textID)) {
listWidgets.update(
textID,
(value) =>
// Text("aaa")
CustomStoryText(
textInfo: textsMapInfo[textID],
screenWidth: screenWidth,
screenColorsList: screenColorsList));
} else {
listWidgets[iD] =
// Text("${textID}");
CustomStoryText(
textInfo: textsMapInfo[iD],
screenWidth: screenWidth,
screenColorsList: screenColorsList);
}
print("UPDAAATE");
notifyListeners();
}
}
*i pass widgets and list into Stack * also we can create some of this widgets
Stack(
fit: StackFit.expand,
children: ctx.watch<ProviderStoryCustomText>().listWidgets.values.toList(),
)
and at the end my customTextStory Constractor
class CustomStoryImage extends StatefulWidget {
const CustomStoryImage({
Key? key,
required this.imgFile,
required this.screenHeight,
required this.screenWidth,
}) : super(key: key);
final File imgFile;
final double? screenWidth;
final double? screenHeight;
@override
State<CustomStoryImage> createState() => _CustomStoryImageState();
}
class _CustomStoryImageState extends State<CustomStoryImage> {...}
Thank you @pskink
as you said the solution it is
for managing stateFulwidgets have you pass them key: UniqueKey(),
the uniqueKey work as well for each statefulWidget
if you want have multi of them in your list also you can update,remove them as well
Thank you again @pslink for Helping to solve this question
on this link flutter team will explain complitly