Skip to content

Instantly share code, notes, and snippets.

@RedBrogdon
Created June 26, 2023 20:59
Show Gist options
  • Save RedBrogdon/dfabe09f439bf91432f1162e3336eca6 to your computer and use it in GitHub Desktop.
Save RedBrogdon/dfabe09f439bf91432f1162e3336eca6 to your computer and use it in GitHub Desktop.
mellow-illusion-3502

mellow-illusion-3502

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
//Import the font package
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
const appName = 'Custom Themes';
return MaterialApp(
title: appName,
theme: ThemeData(
useMaterial3: true,
// Define the default brightness and colors.
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.purple,
brightness: Brightness.dark,
),
// Define the default `TextTheme`. Use this to specify the default
// text styling for headlines, titles, bodies of text, and more.
textTheme: TextTheme(
displayLarge: const TextStyle(fontSize: 72, fontWeight: FontWeight.bold),
titleLarge: GoogleFonts.oswald(fontSize: 30, fontStyle: FontStyle.italic),
bodyMedium: GoogleFonts.merriweather(),
displaySmall: GoogleFonts.pacifico(),
),
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Colors.pink,
splashColor: Colors.yellow,
),
),
home: const MyHomePage(
title: appName,
),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
const MyHomePage({super.key, required this.title});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
color: theme.colorScheme.primary,
child: Text(
'Text with a background color',
style: theme.textTheme.bodyMedium,
),
),
),
floatingActionButton: Theme(
data: ThemeData(
floatingActionButtonTheme: theme.floatingActionButtonTheme.copyWith(splashColor: Colors.blue),
),
child: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment