Skip to content

Instantly share code, notes, and snippets.

@atsansone
Created June 29, 2023 01:28
Show Gist options
  • Select an option

  • Save atsansone/ce48bfbf16730cbd04a79d2eb8fc1f0f to your computer and use it in GitHub Desktop.

Select an option

Save atsansone/ce48bfbf16730cbd04a79d2eb8fc1f0f to your computer and use it in GitHub Desktop.
cylindrical-gust-3792

cylindrical-gust-3792

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
//Import the google_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) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
color: Theme.of(context).colorScheme.primary,
child: Text(
'Text with a background color',
style: Theme.of(context).textTheme.bodyMedium,
),
),
),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(
floatingActionButtonTheme: const FloatingActionButtonThemeData(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