mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-05-23 07:56:28 +08:00
refactoring and added comments
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import './utils.dart' as utils;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(new MaterialApp(
|
runApp(new MaterialApp(
|
||||||
// Title
|
// Title
|
||||||
@ -17,12 +19,10 @@ void main() {
|
|||||||
child: new Center(
|
child: new Center(
|
||||||
// Add Text
|
// Add Text
|
||||||
child: new Text("The quick brown fox jumps over the lazy dog",
|
child: new Text("The quick brown fox jumps over the lazy dog",
|
||||||
|
// Center align text
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
// set a text style which defines a custom font
|
||||||
color: Colors.blueAccent,
|
style: utils.getCustomFontTextStyle()),
|
||||||
fontFamily: 'Pacifico',
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 36.0)),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
14
using_custom_fonts/lib/utils.dart
Normal file
14
using_custom_fonts/lib/utils.dart
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
TextStyle getCustomFontTextStyle() {
|
||||||
|
// text style which defines a custom font
|
||||||
|
return const TextStyle(
|
||||||
|
// set color of text
|
||||||
|
color: Colors.blueAccent,
|
||||||
|
// set the font family as defined in pubspec.yaml
|
||||||
|
fontFamily: 'Pacifico',
|
||||||
|
// set the font weight
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
// set the font size
|
||||||
|
fontSize: 36.0);
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import './utils.dart' as utils;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(new MaterialApp(
|
runApp(new MaterialApp(
|
||||||
// Title
|
// Title
|
||||||
@ -20,13 +22,8 @@ void main() {
|
|||||||
"Hello World!",
|
"Hello World!",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Set background
|
||||||
decoration: new BoxDecoration(
|
decoration: new BoxDecoration(
|
||||||
// Add Gradient
|
// Add Gradient
|
||||||
gradient: new LinearGradient(
|
gradient: utils.getCustomGradient())))));
|
||||||
colors: [Colors.lightBlueAccent, Colors.blueAccent],
|
|
||||||
begin: const FractionalOffset(0.0, 0.0),
|
|
||||||
end: const FractionalOffset(0.6, 0.0),
|
|
||||||
stops: [0.0, 0.6],
|
|
||||||
tileMode: TileMode.clamp),
|
|
||||||
)))));
|
|
||||||
}
|
}
|
||||||
|
11
using_gradient/lib/utils.dart
Normal file
11
using_gradient/lib/utils.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
LinearGradient getCustomGradient() {
|
||||||
|
// Define a Linear Gradient
|
||||||
|
return new LinearGradient(
|
||||||
|
colors: [Colors.lightBlueAccent, Colors.blueAccent],
|
||||||
|
begin: const FractionalOffset(0.0, 0.0),
|
||||||
|
end: const FractionalOffset(0.6, 0.0),
|
||||||
|
stops: [0.0, 0.6],
|
||||||
|
tileMode: TileMode.clamp);
|
||||||
|
}
|
Reference in New Issue
Block a user