I have tried to run my flutter app and it shows unexpected null value after running,on the debug console it shows that the problem is on the AppText.enText[‘welcome Text:’]!, attached is the code for the auth_page class and apptext class
import 'package:flutter/material.dart';
import 'package:laravel/components/login.dart';
import 'package:laravel/utils/config.dart';
import 'package:laravel/utils/text.dart';
class authPage extends StatefulWidget {
const authPage({Key? key}) : super(key: key);
@override
State<authPage> createState() => _authPage();
}
class _authPage extends State<authPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 15),
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
AppText.enText['welcome Text:']!,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 36,
),
),
Config.spaceSmall,
Text(
AppText.enText['signIn Text:']!,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
Config.spaceSmall,
//login components here
loginForm(),
Config.spaceSmall,
Center(
child: TextButton(
onPressed: () {},
child: Text(
AppText.enText['Forgot Password']!,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
)
//18
],
),
)),
);
}
}
```//
the apptext class//
//class App text
class AppText {
static final enText = {
‘welcome Text’: ‘Welcome’,
‘signIn Text’: ‘signIn to your Account’,
‘Register Text’: ‘Already have an Acount’,
‘Registered Text’:
‘You can easily Sign Up and connect to a doctor near you’,
‘SignUp text’: ‘Dont have an account?’,
‘Social login’: ‘or continue with social account’,
‘Forgot Password’: ‘Forgot your Password’,
};
}
I tried running the app but a red screen appeared showing unexpected null value
2
Answers
it is clearly that
AppText.enText
not contains keys likewelcome Text:
andsignIn Text:
, replacewelcome Text:
withwelcome Text
andsignIn Text:
withsignIn Text
.You can try the following code for debug purposes: