Skip to content

Instantly share code, notes, and snippets.

@ha-yi
Created June 9, 2020 03:55
Show Gist options
  • Save ha-yi/62747638af316176165b79b27fbba2c7 to your computer and use it in GitHub Desktop.
Save ha-yi/62747638af316176165b79b27fbba2c7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
extension StringExt on String {
Text toH2(context) {
return Text(this, style: Theme.of(context).textTheme.headline2,);
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
children: [
'Hello World'.toH2(context),
'Hello 2'.toH2(context)
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment