質問編集履歴

3

画面生成処理を追記

2022/10/04 02:08

投稿

Y.Mamoru
Y.Mamoru

スコア47

test CHANGED
File without changes
test CHANGED
@@ -23,7 +23,6 @@
23
23
  ### 該当のソースコード
24
24
 
25
25
  ```dart
26
- //画面をビルドする処理は省いています。
27
26
  //ログイン処理
28
27
  Future<void> _login() async {
29
28
  if (!_formKey.currentState!.validate()) {
@@ -82,6 +81,89 @@
82
81
  context,
83
82
  MaterialPageRoute(builder: (context) => const TabPage()),
84
83
  );
84
+ }
85
+
86
+ //以下ログイン画面生成処理
87
+ @override
88
+ Widget build(BuildContext context) {
89
+ return MaterialApp(
90
+ home:Scaffold(
91
+ appBar: AppBar(
92
+ centerTitle: true,
93
+ title: const Text("ログイン"),
94
+ ),
95
+ body: SafeArea(
96
+ child: _isLoading
97
+ ? const Center(
98
+ child: CircularProgressIndicator(),
99
+ )
100
+ : Form(
101
+ key: _formKey,
102
+ child: Container(
103
+ padding: const EdgeInsets.all(16),
104
+ child: Column(
105
+ children: [
106
+ TextFormField(
107
+ keyboardType: TextInputType.emailAddress,
108
+ decoration: const InputDecoration(
109
+ hintText: "メールアドレス",
110
+ ),
111
+ validator: (emailValue) {
112
+ if (emailValue == null || emailValue == "") {
113
+ return 'メールアドレスは必ず入力してください。';
114
+ }
115
+ _mail = emailValue;
116
+ return null;
117
+ },
118
+ ),
119
+ TextFormField(
120
+ keyboardType: TextInputType.visiblePassword,
121
+ obscureText: isHiddenPassword,
122
+ decoration: InputDecoration(
123
+ hintText: "パスワード",
124
+ suffixIcon: IconButton(
125
+ icon: Icon(isHiddenPassword
126
+ ? Icons.remove_red_eye
127
+ : Icons.visibility_off),
128
+ onPressed: () {
129
+ setState(() {
130
+ isHiddenPassword =!isHiddenPassword;
131
+ });
132
+ }),
133
+ ),
134
+
135
+ validator: (passwordValue) {
136
+ if (passwordValue == null ||
137
+ passwordValue == "") {
138
+ return 'パスワードは必ず入力してください。';
139
+ }
140
+ _password = passwordValue;
141
+ return null;
142
+ },
143
+ ),
144
+ const SizedBox(
145
+ height: 32,
146
+ ),
147
+ ElevatedButton(
148
+ onPressed: () {
149
+ _login();
150
+ },
151
+ child: const Text("ログイン")),
152
+ const SizedBox(
153
+ height: 16,
154
+ ),
155
+ ElevatedButton(
156
+ onPressed: () {
157
+ runApp(const SignUpPage()
158
+ );
159
+ },
160
+ child: const Text("会員登録")),
161
+ const SizedBox(
162
+ height: 16,
163
+ ),
164
+ ],
165
+ ),
166
+ )))));
85
167
  }
86
168
 
87
169
  ```

2

tokenについて追記

2022/10/03 11:23

投稿

Y.Mamoru
Y.Mamoru

スコア47

test CHANGED
File without changes
test CHANGED
@@ -151,6 +151,11 @@
151
151
  これが原因かと思い、local tokenの作成方法を調べていますが、
152
152
  すでに実装コードは書いているので、なぜnullなのかもわかっていない状態です。
153
153
 
154
+ 追記です。
155
+ tokenがnullであることは、もしかしたら問題ないかもしれません。
156
+ 定義の段階でtokenはnull許容であることと、
157
+ ここでのtokenはAPIから受け取る際に使われると参考サイトに書かれていたことから判断しました。
158
+
154
159
 
155
160
 
156
161
 

1

リモート通信であることを明記しました

2022/10/03 11:09

投稿

Y.Mamoru
Y.Mamoru

スコア47

test CHANGED
@@ -1 +1 @@
1
- FlutterからAPI(PHP)へデータ信ができない
1
+ FlutterからAPI(PHP)へ、リモートデータ信ができない
test CHANGED
@@ -1,10 +1,10 @@
1
1
  ### 前提
2
2
  Flutterアプリの画面で入力した内容を、
3
- PHPで作成したAPIに飛ばすのですが
3
+ PHPで作成したAPIにリモートで飛ばすのですが
4
4
  値を飛ばすことができません。
5
5
 
6
6
  ### 実現したいこと
7
- Flutterの画面から入力した値をPHPで作成したAPIで受け取れる、ログイン機能を作成しようとしてます。
7
+ Flutterの画面から入力した値をPHPで作成したAPIに送信する、ログイン機能を作成しようとしてます。
8
8
 
9
9
  ### 発生している問題・エラーメッセージ
10
10
  Flutter側の送信でエラーが起こっているようです。