Flutter: Modifying a state modifies other states using setState in TextField

Viewed 24

When i modify agentName state and switch to the next screen, i see agentName value in clientName. How do i modify just the agentName state and after the screen switch i modify just the clientName?

Screens(
  index: index,
  children: [
    Screen(
        child: Column(
        children: [
          Field(
          onChanged: (String value) => setState(() => agentName = value)
          ),
          ScreenButtons(
            previous: () => setState(() => index--), 
            next: () => setState(() => index++), 
            index: index, 
            length: 2
          )
        ]
      )
    ),
    Screen(
      child: Column(
        children: [
          Field(
            onChanged: (String value) => setState(() => clientName = value),
          ),
          ScreenButtons(
            previous: () => setState(() => index--), 
            next: () => setState(() => index++), 
            index: index, 
            length: 2
          )
        ]
      )
    )
  ]
);
1 Answers

I've solved it using IndexedStack widget.

Related