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

Time:07-07

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...

CodePudding user response:


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 
  • Related