Skip to content

Instantly share code, notes, and snippets.

@VintageAppMaker
Created October 19, 2022 10:24
Show Gist options
  • Save VintageAppMaker/e228310a2a55299ea270c562ab3fccd0 to your computer and use it in GitHub Desktop.
Save VintageAppMaker/e228310a2a55299ea270c562ab3fccd0 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var lst = <Widget>[];
var testString = "안녕하세요. Hi there, 12345";
@override
void initState() {
var fonts = [
FontData(
fontName: "GoogleFonts.notoSans()",
style: GoogleFonts.notoSans(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.cuteFont()",
style: GoogleFonts.cuteFont(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.songMyung()",
style: GoogleFonts.songMyung(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.dokdo()",
style: GoogleFonts.dokdo(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.poorStory()",
style: GoogleFonts.poorStory(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.gowunBatang()",
style: GoogleFonts.gowunBatang(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.gowunDodum()",
style: GoogleFonts.gowunDodum(color: Colors.black, fontSize: 18),
testString: testString),
FontData(
fontName: "GoogleFonts.blackAndWhitePicture()",
style: GoogleFonts.blackAndWhitePicture(
color: Colors.black, fontSize: 18),
testString: testString)
];
for (var i = 0; i < fonts.length; i++) {
lst.add(buildBar(fonts[i]));
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Center(
child: Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'GoogleFonts Test',
),
SizedBox(
height: 10,
),
...lst.toList()
],
),
),
),
),
);
}
}
class FontData {
late String fontName = "";
late TextStyle style;
late String testString;
FontData(
{required this.fontName, required this.style, required this.testString});
}
Widget buildBar(FontData item) {
return Container(
width: double.infinity,
margin: EdgeInsets.all(10),
color: Color(0xffededed),
child: Column(
children: [
Text(
"${item.fontName}",
style: TextStyle(fontSize: 20, color: Colors.grey),
),
Container(
padding: EdgeInsets.only(top: 15, bottom: 13),
child: Text(
item.testString,
style: item.style,
textAlign: TextAlign.center,
),
),
],
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment