2
answers
1
watching
266
views

For flutter 3.3.2 fixed the return statement now having issues with the following lines - lib/main.dart(16,18): error G4127D1E8: The getter '_formkey' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(28,23): error G4127D1E8: The getter 'loginData' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(46,23): error G4127D1E8: The getter 'loginData' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(56,27): error G4127D1E8: The getter '_formkey' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(57,25): error G4127D1E8: The getter '_formkey' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(59,52): error G4127D1E8: The getter 'loginData' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]
lib/main.dart(62,52): error G4127D1E8: The getter 'loginData' isn't defined for the class 'MyAppState'. [D:\form_widget5\build\windows\flutter\flutter_assemble.vcxproj]

Full code listed below

 

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body : Container(
padding : const EdgeInsets.all(50.0),
child : Form(
key: _formkey,
child: Column(
children: [
TextFormField(
keyboardType: TextInputType.emailAddress,
validator: (String? inValue) {
if (inValue?.isEmpty?? true) {
return "Please enter username";
}
return null;
},
onSaved: (String? inValue) {
loginData.username = inValue!;
},
decoration: const InputDecoration(
hintText: "[email protected]",
labelText: "Username (eMail address)"
),
),
TextFormField(
obscureText: true,
validator: (String? inValue) {
if (inValue == null) {
return "Password cannot be null";
} else if (inValue.length < 10) {
return "Password must be >= 10 in length";
}
return null;
},
onSaved: (String? inValue) {
loginData.password = inValue!;
},
decoration: const InputDecoration(
hintText : "Password",
labelText : "Password"
),
),
ElevatedButton(
child : const Text("Log In!"),
onPressed: (){
if (_formkey.currentState!.validate()){
_formkey.currentState!.save();
if (kDebugMode) {
debugPrint ("Username: ${loginData.username}");
}
if (kDebugMode) {
debugPrint ("Password: ${loginData.password}");
}
}
},
),
]
),
),
),
),
);
}
}

class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
MyAppState createState() => MyAppState();
}

class LoginData {
String username = "";
String password = "";
}

For unlimited access to Homework Help, a Homework+ subscription is required.

Avatar image
Liked by dragon2020 and 3 others

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in
Avatar image
Liked by dragon2020 and 2 others
Already have an account? Log in

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in