Issue
I am declaring
static var screenHeight;
static var screenWidth;
Yet dart analysis is flagging it as Prefer typing uninitialized variables and fields. (prefer_typing_uninitialized_variables...
screenHeight = MediaQuery.of(context).size.height;
screenWidth = MediaQuery.of(context).size.width;
Solution
As you are not instantiating while declaring variables, it is often good practice to declare type beforehand. So just replace var with the explicit types. Replace var with double in this case.
static double screenHeight;
static double screenWidth;
Or, you can do this
static double screenHeight = MediaQuery.of(context).size.height;
static double screenWidth = MediaQuery.of(context).size.width;
Answered By - Varun Kumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.