Don't know what to put the return value in the return line (The last line) see below for Flutter.
class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context) {
return;
The entire 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;
}
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
MyAppState createState() => MyAppState();
}
class LoginData {
String username = "";
String password = "";
}
class _MyApp extends State {
LoginData loginData = LoginData();
final GlobalKey<FormState> _formkey = GlobalKey<FormState>();
@override
Widget build(BuildContext inContext) {
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}");
}
}
},
),
]
),
),
),
));
}
}
Don't know what to put the return value in the return line (The last line) see below for Flutter.
class MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context) {
return;
The entire 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;
}
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
MyAppState createState() => MyAppState();
}
class LoginData {
String username = "";
String password = "";
}
class _MyApp extends State {
LoginData loginData = LoginData();
final GlobalKey<FormState> _formkey = GlobalKey<FormState>();
@override
Widget build(BuildContext inContext) {
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}");
}
}
},
),
]
),
),
),
));
}
}