Skip to content

Instantly share code, notes, and snippets.

@emmanuelrosa
Created October 11, 2025 16:55
Show Gist options
  • Save emmanuelrosa/16938813d6af81e06d99738825584804 to your computer and use it in GitHub Desktop.
Save emmanuelrosa/16938813d6af81e06d99738825584804 to your computer and use it in GitHub Desktop.
Changes I made to get app to match what is shown in the Flutter theme lesson.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
brightness: Brightness.dark,
appBarTheme: AppBarTheme(
centerTitle: true,
toolbarHeight: 150, // Change to 150.
shadowColor: Colors.yellow,
elevation: 5, // Add an elevation to make shadow visible.
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Colors.yellow,
/*
* The "+" in the action button defaults to a light color,
* which makes it hard to see against the yellow background color.
* So, I changed the [foregroundColor].
*/
foregroundColor: Colors.black,
),
fontFamily: 'Georgia',
textTheme: TextTheme(
// There's no [headline4].
headlineMedium: TextStyle(fontSize: 36, fontStyle: FontStyle.italic),
),
/*
* The default template adds a purple [colorScheme]. This conflicts with
* [brightness], so I removed it.
*/
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment