cute_theme

Creator: coderz1093

Last updated:

0 purchases

cute_theme Image
cute_theme Images

Languages

Categories

Add to Cart

Description:

cute theme

Getting started #
In your flutter project add the dependency:
dependencies:
...
cute_theme_annotation: any

dev_dependencies:
...
cute_theme: any
build_runner: any
copied to clipboard
Usage example #
Import flutter_cute.dart and add part directive
import 'package:cute_theme_annotation/cute_theme_annotation.dart';

part 'app_theme.cute.dart';
copied to clipboard
Create base theme class #
@CuteTheme()
class $AppTheme {
$AppTheme({
required Brightness brightness,
required Color colorBackground,
required BorderRadius borderRadiusMd,
required TextStyle textTitleSmall,
required EdgeInsets paddingMd,
});
}
copied to clipboard
Run the code generator #
flutter run build_runner build --delete-conflicting-outputs
copied to clipboard
Create themes #
class AppThemes {
static AppTheme get light {
return AppTheme(
brightness: Brightness.light,
colorBackground: Colors.white,
borderRadiusMd: BorderRadius.circular(8),
textTitleSmall: TextStyle(fontWeight: FontWeight.w500),
paddingMd: BorderRadius.circular(8),
);
}

static AppTheme get dark {
return AppTheme(
brightness: Brightness.dark,
colorBackground: Colors.black,
borderRadiusMd: BorderRadius.circular(8),
textTitleSmall: TextStyle(fontWeight: FontWeight.w500),
paddingMd: EdgeInsets.all(8),
);
}
}
copied to clipboard
Add extensions #
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: AppThemes.light.brightness,
extensions: [AppThemes.light]
),
darkTheme: ThemeData(
brightness: AppThemes.dark.brightness,
extensions: [AppThemes.dark]
),
);
}
copied to clipboard
And finally use it! #
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
color: AppTheme.of(context).colorBackground,
borderRadius: AppTheme.of(context).borderRadiusMd,
),
child: Padding(
padding: AppTheme.of(context).paddingMd,
child: Text("CuteTheme", style: AppTheme.of(context).textTitleSmall),
),
);
}
copied to clipboard
Example #
Github

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.