「労働者が自分の仕事をうまくやりたいなら、まず自分の道具を研ぎ澄まさなければなりません。」 - 孔子、「論語。陸霊公」
表紙 > プログラミング > ページから別のフラッター/ダーツに変数を送信する方法

ページから別のフラッター/ダーツに変数を送信する方法

2024 年 11 月 8 日に公開
ブラウズ:379

how to send variables from a page to another flutter/dart

こんにちは。現在、アプリケーションのメイン ページへの接続ステップ中にユーザーによる変数エントリを渡そうとしていますが、エラーが発生しました。原因がわかりません。 、私のページのメイン(ゲームページ)の男の子の子の中で、コントローラーのアドレスを表示したいのですが、フラッターはこの変数が定義されていないと言います!!!!
あなたは私の唯一の希望です

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart';
import 'package:http/http.dart' as http;
import 'package:tentative_formulaire_konamicash/stfgamepage.dart';

class register extends StatefulWidget {
  const register({super.key});

  @override
  State createState() => _registerState();
}

class _registerState extends State {
  final _formKey = GlobalKey();
  final controllermail = TextEditingController();
  final controllerpassword = TextEditingController();

  Future login(String mail, String password) async {
    try {
      var url = Uri.parse('https://konamicash.com/authentification_app');
      var response = await http.post(
        url,
        headers: {
          "Accept": "application/json",
          "Access-Control-Allow-Origin": "*"
        },
        body: {
          "the_mail": mail,
          "the_pasword": password,
        },
      );
      if (response.statusCode == 200) {
        var data = jsonDecode(response.body);
        print('OK: $data');
        if (data['authentification'] == 0) {
        } else {
          Navigator.push(
              context,
              PageRouteBuilder(
                pageBuilder: (context, animation, secondaryAnimation) => Gaming(
                  formKey: GlobalKey(),
                  controlleradressemail:TextEditingController(),
                  controllermotdepasse : TextEditingController(),
                ),
              ));
        }
      }
    } catch (e) {
      print('An error occurred: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('nami'),
      ),
      body: Form(
        key: _formKey,
        child: Column(
          children: [
            Container(
              child: TextFormField(
                decoration: const InputDecoration(labelText: 'mail'),
                controller: controllermail,
              ),
            ),
            Container(
              child: TextFormField(
                decoration: const InputDecoration(labelText: 'password'),
                controller: controllerpassword,
              ),
            ),
            SizedBox(
              width: double.infinity,
              height: 50,
              child: ElevatedButton(
                onPressed: () {
                  final mail = controllermail.text;

                  final password = controllerpassword.text;

                  login(mail, password);
                },
                child: const Text('Connexion'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

リリースステートメント この記事は次の場所に転載されています: https://dev.to/deenan_djigbenou_ba0ce10e/how-to-send-variables-from-a-page-to-another-flutterdart-10n6?1 侵害がある場合は、study_golang@163 までご連絡ください。 .comを削除してください
最新のチュートリアル もっと>

免責事項: 提供されるすべてのリソースの一部はインターネットからのものです。お客様の著作権またはその他の権利および利益の侵害がある場合は、詳細な理由を説明し、著作権または権利および利益の証拠を提出して、電子メール [email protected] に送信してください。 できるだけ早く対応させていただきます。

Copyright© 2022 湘ICP备2022001581号-3