refactoring and added comments

This commit is contained in:
Nishant Srivastava
2017-09-29 23:38:41 -07:00
parent 5b7434fb2a
commit 351b44db0e
4 changed files with 35 additions and 13 deletions

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import './utils.dart' as utils;
void main() {
runApp(new MaterialApp(
// Title
@ -17,12 +19,10 @@ void main() {
child: new Center(
// Add Text
child: new Text("The quick brown fox jumps over the lazy dog",
// Center align text
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.blueAccent,
fontFamily: 'Pacifico',
fontWeight: FontWeight.w400,
fontSize: 36.0)),
// set a text style which defines a custom font
style: utils.getCustomFontTextStyle()),
),
),
)));

View 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);
}

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import './utils.dart' as utils;
void main() {
runApp(new MaterialApp(
// Title
@ -20,13 +22,8 @@ void main() {
"Hello World!",
),
),
// Set background
decoration: new BoxDecoration(
// Add Gradient
gradient: 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),
)))));
// Add Gradient
gradient: utils.getCustomGradient())))));
}

View 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);
}