Skip to content

Commit 6eb821b

Browse files
committed
✨ feat(all): 移除冗余引入,美化appbar
1 parent 8be7467 commit 6eb821b

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*.ipr
1515
*.iws
1616
.idea/
17+
.vscode
1718

1819
# The .vscode folder contains launch configuration and tasks you configure in
1920
# VS Code which you may wish to be included in version control, so this line

lib/config.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22

33
const appConfig = {'title': 'flutter个人博客模板'};
44

5-
const baseUrl = 'http://2.0.1.173:3001';
5+
const baseUrl = 'http://2.0.2.44:3001';
66

77
const primaryColor = const MaterialColor(
88
0xFF66BB6A,

lib/pages/article.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import 'package:blog_flutter/config.dart';
22
import 'package:flutter/material.dart';
33

44
class ArticleWidget extends StatelessWidget {
5-
final article;
6-
7-
ArticleWidget({Key key, @required this.article}) : super(key: key);
5+
ArticleWidget({Key key}) : super(key: key);
86

97
@override
108
Widget build(BuildContext context) {
119
final Map params = ModalRoute.of(context).settings.arguments;
1210

1311
return Scaffold(
14-
appBar: AppBar(title: Text(params['title'])),
12+
appBar: AppBar(
13+
centerTitle: true,
14+
title: Text(
15+
params['title'],
16+
style: TextStyle(color: Colors.amberAccent),
17+
)),
1518
body: Container(
1619
width: MediaQuery.of(context).size.width,
1720
height: MediaQuery.of(context).size.height,

lib/pages/home.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ class HomeWidgetState extends State<HomeWidget> {
4444
Widget build(BuildContext context) {
4545
return Scaffold(
4646
appBar: AppBar(
47-
title: Center(
48-
child: Text(
49-
appConfig['title'],
50-
style: TextStyle(color: Colors.white),
51-
)),
52-
),
47+
centerTitle: true,
48+
title: Text(
49+
appConfig['title'],
50+
style: TextStyle(color: Colors.amberAccent),
51+
)),
5352
body: RefreshIndicator(
5453
onRefresh: _handlePullDownRefresh,
5554
child: ListView.separated(

lib/pages/login.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:blog_flutter/config.dart';
22
import 'package:blog_flutter/services/user_service.dart';
33
import 'package:flutter/material.dart';
4-
import 'package:fluttertoast/fluttertoast.dart';
54

65
class LoginWidget extends StatefulWidget {
76
@override
@@ -36,14 +35,20 @@ class LoginWidgetState extends State<LoginWidget> {
3635
TextFormField(
3736
autofocus: true,
3837
controller: _userNameController,
39-
decoration: InputDecoration(labelText: "用户名", hintText: "用户名或邮箱", icon: Icon(Icons.person)),
38+
decoration: InputDecoration(
39+
labelText: "用户名",
40+
hintText: "用户名或邮箱",
41+
icon: Icon(Icons.person)),
4042
// 校验用户名
4143
validator: (v) {
4244
return v.trim().length > 0 ? null : "用户名不能为空";
4345
}),
4446
TextFormField(
4547
controller: _passwordController,
46-
decoration: InputDecoration(labelText: "密码", hintText: "您的登录密码", icon: Icon(Icons.lock)),
48+
decoration: InputDecoration(
49+
labelText: "密码",
50+
hintText: "您的登录密码",
51+
icon: Icon(Icons.lock)),
4752
obscureText: true,
4853
//校验密码
4954
validator: (v) {
@@ -58,16 +63,19 @@ class LoginWidgetState extends State<LoginWidget> {
5863
child: ElevatedButton(
5964
child: Text("登录"),
6065
style: ButtonStyle(
61-
foregroundColor: MaterialStateProperty.all(Colors.white),
62-
backgroundColor: MaterialStateProperty.resolveWith((states) {
66+
foregroundColor:
67+
MaterialStateProperty.all(Colors.white),
68+
backgroundColor:
69+
MaterialStateProperty.resolveWith((states) {
6370
if (states.contains(MaterialState.pressed)) {
6471
return primaryColor[600];
6572
}
6673
return primaryColor;
6774
})),
6875
onPressed: () {
6976
if ((_formKey.currentState as FormState).validate()) {
70-
_login(_userNameController.text, _passwordController.text);
77+
_login(_userNameController.text,
78+
_passwordController.text);
7179
}
7280
},
7381
),

lib/services/http.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:blog_flutter/config.dart';
22
import 'package:dio/dio.dart';
3-
import 'package:flutter/material.dart';
43
import 'package:fluttertoast/fluttertoast.dart';
54

65
class Http {

0 commit comments

Comments
 (0)