Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How should I create my String variables? with class or Not?

I’m new on FLutter and I’m working on Flutter app projects for more learn and I have a question about the keeping String values. On the Some flutter app tutorial videos, the guy keeping all String value in any dart file.
For example:

//Login Page
const String loginButton = 'LogIn';
const String registerQuestionText = 'Do You Have Any Account?';
const String registerButtonText = 'SingIn!';
const String usernameText = 'Username';
const String passwordText = 'Password';


//Register Page
const String emailText = 'Email';
const String bookText = 'Favorite Book';
const String passwordVerifyText = 'Password Again';

here on the other way, someones doing like that:

class ProjectKeys {
  static final String appBarTitle = "Hello";
  static final String buttonLabel = "Press The Button";
}

So, I’m confused about these usages. Which one should I use for clean code?
Thanks in advance…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :


class ProjectKeys {
  static final String appBarTitle = "Hello";
  static final String buttonLabel = "Press The Button";
}

if your using this you can use your String as ProjectKeys.appBarTitle
which ia object based approach 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading