Skip to content

Example how to manage styles in Flutter with Bloc

Notifications You must be signed in to change notification settings

katafo/flutter_styles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_styles

Example how to manage your app styles with Bloc.

Getting Started

1. Create interface named AppStyles, and define all styles you need for your app in here:

abstract class AppStyles {
  ThemeData getThemeData();
}

2. Each app style will extends from AppStyles interface. So it will required you override all method of AppStyles.

class DefaultStyles implements AppStyles {

  @override
  ThemeData getThemeData() {
    return ThemeData(
        fontFamily: AppFonts.openSans,
        visualDensity: VisualDensity.adaptivePlatformDensity,
        primarySwatch: AppColors.grey,
        primaryColor: AppColors.white,
        brightness: Brightness.light,
        backgroundColor: AppColors.white  ,
        scaffoldBackgroundColor:AppColors.white);
  }
}
class DarkStyles implements AppStyles {
  @override
  ThemeData getThemeData() {
    return ThemeData(
      visualDensity: VisualDensity.adaptivePlatformDensity,
      primarySwatch: AppColors.grey,
      primaryColor: AppColors.satinDepBlack,
      brightness: Brightness.dark,
      backgroundColor: AppColors.closeShutter,
      scaffoldBackgroundColor: AppColors.closeShutter,
    );
  }
}

Use interface to ensure all styles you define have the same config.

3. Then create AppCubit which wrap your MaterialApp. So that, you can call your style anywhere in app.

_appCubit.styles.getThemeData()

About

Example how to manage styles in Flutter with Bloc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages