BLoC et création de formulaire

Bonjour,
Je tente mon projet avec BLoC.
J’arrive à récupérer une liste de Famille et à afficher dans un formulaire une Famille particulière.
Mon formulaire aura 2 mode : lecture et édition (lors du clique sur bouton edit).
J’aimerai pouvoir passer en mode édition et si l’utilisateur ne souhaite pas faire la modification repasser en lecture. Cela fontionne à moitié j’arrive à rebloquer mes champs mais la modification effectuée est toujours visible. J’aimerai retourner dans l’état initial.

class FamilyDetailsPage extends StatelessWidget {
  const FamilyDetailsPage({Key? key, required this.family}) : super(key: key);
  final Family family;
  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => FamilyBloc(repository: FamilyRepository()),
      child: FamilyDetailsView(family: family),
    );
  }
}

class FamilyDetailsView extends StatefulWidget {
  const FamilyDetailsView({Key? key, required this.family}) : super(key: key);
  final Family family;
  @override
  State<FamilyDetailsView> createState() => FamilyDetailsViewState();
}

class FamilyDetailsViewState extends State<FamilyDetailsView>
    with SingleTickerProviderStateMixin {
  late FamilyBloc _familyBloc;
  late bool isUpdated;
  late final Family _initFamily = widget.family;
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  static final GlobalKey<FormState> _formKey =
      GlobalKey<FormState>(debugLabel: '_appFamilyFormState');
  static final _familyKey =
      GlobalKey<FamilyFormState>(debugLabel: '_appFamilyState');
  static final _usersKey = GlobalKey<FormState>(debugLabel: '_appUsersState');
  //static final _loansKey = GlobalKey<FormState>(debugLabel: '_appLoansState');
  late TabController _controllerTab;

  @override
  void initState() {
    super.initState();
    _controllerTab = TabController(vsync: this, length: 3);
    isUpdated = (widget.family.id != 0) ? false : true;
    _familyBloc = BlocProvider.of<FamilyBloc>(context);
  }

  @override
  void dispose() {
    _controllerTab.dispose();
    _familyBloc.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final l10n = AppLocalizations.of(context)!;
    return WillPopScope(
      onWillPop: () async {
        if (!isUpdated || widget.family.id == 0) {
          Navigator.of(context).pushReplacement(
              MaterialPageRoute(builder: (context) => const FamilyPage()));
          return true;
        }
        setState(() => isUpdated = false);
        return false;
      },
      child: Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: BlocBuilder<FamilyBloc, FamilyState>(
            builder: (context, state) => isUpdated
                ? Text(
                    '${state.item?.id == 0 ? l10n.addText : l10n.editText} ${l10n.familyText}')
                : Text(l10n.familyText),
          ),
          actions: <Widget>[
            !isUpdated
                ? IconButton(
                    onPressed: () {
                      setState(() => isUpdated = true);
                    },
                    icon: const Icon(Icons.edit))
                : IconButton(
                    onPressed: () {
                      _saveFamily();
                      setState(() => isUpdated = false);
                    },
                    icon: const Icon(Icons.save),
                  ),
          ],
          bottom: widget.family.id != 0
              ? TabBar(
                  controller: _controllerTab,
                  tabs: [
                    Tab(text: l10n.familyText),
                    const Tab(text: 'Membres'),
                    const Tab(text: 'Emprunts'),
                  ],
                )
              : null,
        ),
        body: Form(
            key: _formKey,
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: widget.family.id != 0
                  ? Column(
                      children: [
                        Flexible(
                            child: TabBarView(
                          controller: _controllerTab,
                          children: <Widget>[
                            FamilyForm(
                                key: _familyKey,
                                item: widget.family,
                                isUpdated: isUpdated),
                            CustomScrollView(slivers: [
                              SliverFillRemaining(
                                  child: Column(children: [
                                Expanded(
                                  child: UserList(
                                      key: _usersKey,
                                      list: widget.family.users!,
                                      isUpdated: isUpdated),
                                ),
                              ]))
                            ]),
                            SingleChildScrollView(
                                child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: const [Text('Loans List')])),
                          ],
                        )),
                      ],
                    )
                  : FamilyForm(
                      key: _familyKey,
                      item: widget.family,
                      isUpdated: isUpdated),
            )),
      ),
    );
  }

  _saveFamily() {
    if (_formKey.currentState != null) {
      if (_formKey.currentState!.validate()) {
        _familyBloc.add(widget.family.id == 0
            ? CreateFamilyEvent(item: widget.family)
            : UpdateFamilyEvent(item: widget.family));
      }
    }
  }
}

Bonjour,
J’ai trouvé la réponse, dans Mon FamilyForm je ne regardé pas le bon state.
ainsi je ne revenais pas à mon état initial.

Bonne journée,

2 J'aime