I'm new to Flutter for a month. Currently I'm facing below issue where showing undefined name 'context'. I have follow the suggestion to import 'dart:js' and it show error "The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'."
import 'package:dparking/reusable_widgets/reusable_widget.dart';
import 'package:dparking/screens/signup_screen.dart';
import 'package:flutter/material.dart';
class SignInScreen extends StatefulWidget {
const SignInScreen({Key? key}) : super(key: key);
@override
State<SignInScreen> createState() => _SignInScreenState();
}
class _SignInScreenState extends State<SignInScreen> {
final TextEditingController _passwordTextController = TextEditingController();
final TextEditingController _emailTextController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Colors.blue,
Colors.green,
], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.fromLTRB(
20, MediaQuery.of(context).size.height * 0.2, 20, 0),
child: Column(
children: <Widget>[
logoWidget("assets/images/DParking.png"),
const SizedBox(
height: 30,
),
reusableTextField("Enter UserName", Icons.person_outline, false,
_emailTextController),
const SizedBox(
height: 20,
),
reusableTextField("Enter Password", Icons.lock_outline, true,
_passwordTextController),
const SizedBox(
height: 20,
),
signInSignUpButton(context, true, () {}),
signUpOption()
],
),
),
),
),
);
}
}
Row signUpOption() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Don't have account?",
style: TextStyle(color: Colors.white70)),
GestureDetector(
onTap: () {
Navigator.push(context, //<- error on this line
MaterialPageRoute(builder: (context) => SignUpScreen()));
},
child: const Text(
" Sign Up",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
)
],
);
}
Please give me some advice on how can I solve this issue. thank you.