Skip to content

Repository files navigation

flutter_theme

  • config/theme.dart
import'package:flutter/material.dart';
ThemeDatatheme() {
returnThemeData(
scaffoldBackgroundColor:Colors.white,
fontFamily:"Avenir",
textTheme:textTheme(),
);
}
TextThemetextTheme() {
returnTextTheme(
headline1:TextStyle(
color:Colors.black,
fontSize:32,
fontWeight:FontWeight.bold,
),
headline2:TextStyle(
),
headline3:TextStyle(
),
headline4:TextStyle(
),
headline5:TextStyle(
),
headline6:TextStyle(
),
bodyText1:TextStyle(
),
bodyText2:TextStyle(
),
);
}
  • main.dart
import'package:flutter/material.dart';
import'config/theme.dart';
voidmain() {
runApp(MyApp());
}
classMyAppextendsStatelessWidget {
// This widget is the root of your application.@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
title:'Flutter Demo',
theme:theme(),
onGenerateRoute:AppRouter.onGenerateRoute,
initialRoute:HomeScreen.routeName,
);
}
}
  • How to use
Text(
this.title,
style:Theme.of(context).textTheme.headline2!.copyWith(color:Colors.white),
)

Copyright 2021 M. Fadli Zein

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages