Skip to content

Instantly share code, notes, and snippets.

@spydon
Created May 27, 2022 12:11
Show Gist options
  • Save spydon/ca65097d19cc31f06431e7c6df24d4e0 to your computer and use it in GitHub Desktop.
Save spydon/ca65097d19cc31f06431e7c6df24d4e0 to your computer and use it in GitHub Desktop.
Repro of DartPad issue #2286
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme(
headline1: GoogleFonts.oswald(
fontSize: 35,
),
headline2: GoogleFonts.lato(
fontSize: 25,
fontStyle: FontStyle.italic,
),
),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
),
);
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
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) {
final TextStyle headline1 = Theme.of(context).textTheme.headline1!;
final TextStyle headline2 = Theme.of(context).textTheme.headline2!;
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'You have pushed the button this many times:',
style: headline1,
textAlign: TextAlign.center,
),
Text(
'$_counter',
style: headline2,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment