Как мне соединить двух пользователей, чтобы они перешли на одинаковый по виду экран и сделали карточку совей дружбы(Container)?

Мне очень нужно чтобы один пользователь искал другого человека по никнейму и если находит то получает в центре экрана всплывающее меню с текстом о том, что другой пользователь принял запрос в друзья, или же его отклонил(FirstPage). Во время поиска друга по имени, другому приходит запрос в виде всплывающего меню на экране о том, что '$user хочет с вами подружится' и если он принимает то их перекидает на одинаковый по виду экран(SecondScreen), где они самостоятельно заполняют свои карточки(вписывает никнеймы друг друга, статус дружбы и комментарий к первой встрече) и это добавляется в список и ретранслируется на другом экране в ListView. Когда один из них кого-то удаляет, то у одного, пропадает эта карточка(удаляется с экрана и в массиве для ListView), а у другого на ней появляется текст 'недействительно'

import '../common/text_Styles.dart';

class MyHomePage extends StatelessWidget {
  TextEditingController nameController = TextEditingController();
  MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final model = Provider.of<UserNameSaver>(context);
    return Scaffold(
      backgroundColor: Colors.redAccent,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              height: 70,
              width: 70,
              child: const Placeholder(
                color: Colors.white,
              ),
            ),

            const SizedBox(height: 10),

            Text(
                model.getNickName,
                style: const TextStyle(color: Colors.white, fontSize: 16)
            ),

            const SizedBox(height: 50),

            Container(
              height: 40,
              width: 220,
              alignment: Alignment.center,
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(
                  Radius.circular(16.0),
                ),
              ),
              child: TextFormField(
                controller: nameController,
                textAlign: TextAlign.center,
                decoration: const InputDecoration.collapsed(hintText: 'Enter Nick Name', border: InputBorder.none),
                keyboardType: TextInputType.emailAddress,
                style: sizeTextBlack(),
              ),
            ),

            const SizedBox(height: 10),

            Container(
              width:160.0,
              alignment: Alignment.center,
              child: ElevatedButton(
                style: ElevatedButton.styleFrom(primary: Colors.blueGrey),
                child: Text('Make a new friend ', style: sizeTextWhite()),
                onPressed: () {
                  Navigator.push(context, MaterialPageRoute(builder: (context) => SecondScreenwq(NotName: nameController.text)));
                },
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.chat, size: 30),
        backgroundColor: Colors.blueGrey,
        onPressed: () {
          Navigator.push(context, MaterialPageRoute(builder: (context) => ScreenPageThree()));
        },
        elevation: 5,
        tooltip: 'Watch your friendcards',
      ),
    );
  }
}

Экран создания этой карточки дружбы

import '../common/text_Styles.dart';

class SecondScreenwq extends StatefulWidget {
  String NotName;
  SecondScreenwq({Key? key, required this.NotName}) : super(key: key);
  @override
  _SecondScreenState createState() => _SecondScreenState(nameNot: NotName);
}

class _SecondScreenState extends State<SecondScreenwq> {
  String nameNot;
  _SecondScreenState({required this.nameNot});

  final formKey = GlobalKey<FormState>();
  TextEditingController CommentTextEditingController = new TextEditingController();
  TextEditingController FieldTextEditingController = new TextEditingController();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.redAccent,
      appBar: AppBar(
        title: const Text('New Notimy'),
        backgroundColor: Colors.redAccent,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            //SizedBox(height: 180.0),

            Container(
              height: 40.0,
              width: 240.0,
              alignment: Alignment.center,
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(
                  Radius.circular(16.0), //                 <--- border radius here
                ),
              ),
              child: Text(
                nameNot,
                textAlign: TextAlign.center,
                style: sizeTextBlack(),
              ),
            ),
            const SizedBox(height: 5.0),
            Container(
              height: 40,
              width: 240.0,
              alignment: Alignment.center,
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(
                  Radius.circular(16.0), //                 <--- border radius here
                ),
              ),
              child: TextFormField(
                controller: FieldTextEditingController,
                textAlign: TextAlign.center,
                decoration: const InputDecoration.collapsed(hintText: 'Enter FieldName', border: InputBorder.none),
                keyboardType: TextInputType.emailAddress,
                style: sizeTextBlack(),
              ),
            ),

            const SizedBox(height: 5.0),

            Container(
              height: 160,
              width: 240.0,
              alignment: Alignment.center,
              decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(
                  Radius.circular(16.0), //                 <--- border radius here
                ),
              ),
              child: Padding(
                padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5 ),
                child: Expanded(
                  child: TextFormField(
                    controller: CommentTextEditingController,
                    textAlign: TextAlign.center,
                    decoration: const InputDecoration.collapsed(hintText: 'Enter Comment', border: InputBorder.none),
                    keyboardType: TextInputType.emailAddress,
                    maxLines: 7,
                    style: sizeTextBlack(),
                  ),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Container(
                width:80.0,
                child: ElevatedButton(
                  style: ElevatedButton.styleFrom(primary: Colors.blueGrey),
                  child: Text('Save', style: sizeTextWhite()),
                  onPressed: () {
                    Provider.of<ListNotimies>(context, listen: false).addNotyInList(FieldTextEditingController.text, nameNot, CommentTextEditingController.text);
                    Navigator.push(context, MaterialPageRoute(builder: (context) => const ScreenPageThree()));
                  },
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Ответы (0 шт):