An example of fonts customization in Flutter
pubspec.yaml:
name: Shrine
description: Learn how to use Material for structure and layout.
dependencies:
flutter:
sdk: flutter
intl: ^0.16.1
cupertino_icons: ^1.0.0
shrine_images: 1.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Rubik
fonts:
- asset: fonts/Rubik-Regular.ttf
- asset: fonts/Rubik-Medium.ttf
weight: 500
uses-material-design: true
assets:
- assets/diamond.png
- packages/shrine_images/0-0.jpgapp.dart:
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final _usernameController = TextEditingController();
final _passwordController = TextEditingController();
final _unfocusedColor = Colors.grey[500];
final _usernameFocusNode = FocusNode();
final _passwordFocusNode = FocusNode();
@override
void initState() {
super.initState();
_usernameFocusNode.addListener(() => setState(() {}));
_passwordFocusNode.addListener(() => setState(() {}));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 24.0),
children: <Widget>[
SizedBox(height: 80.0),
Column(
children: <Widget>[
Image.asset('assets/diamond.png'),
SizedBox(height: 16.0),
Text('SHRINE', style: Theme.of(context).textTheme.headline5)
],
),
SizedBox(height: 120.0),
TextField(
controller: _usernameController,
decoration: InputDecoration(
labelText: 'Username',
labelStyle: TextStyle(
color:
_usernameFocusNode.hasFocus ? Theme.of(context).accentColor : _unfocusedColor,
),
),
),
SizedBox(height: 12.0),
TextField(
controller: _passwordController,
decoration: InputDecoration(
labelText: 'Password',
labelStyle: TextStyle(
color:
_usernameFocusNode.hasFocus ? Theme.of(context).accentColor : _unfocusedColor,
),
),
obscureText: true,
),
ButtonBar(
children: <Widget>[
FlatButton(
child: Text('CANCEL'),
onPressed: () {
_usernameController.clear();
_passwordController.clear();
},
),
RaisedButton(
child: Text('NEXT'),
elevation: 8.0,
onPressed: () {
Navigator.pop(context);
},
),
],
),
],
),
),
);
}
}