Skip to content

Commit

Permalink
Merge init codes to lifecycle method didChangeDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
chengww committed Mar 29, 2019
1 parent c40401a commit a03e800
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class _HomePageState extends State<HomePage> {
double _fontSize = 18;

@override
Widget build(BuildContext context) {
void didChangeDependencies() {
super.didChangeDependencies();
getFontSize().then((value) {
if (value != _fontSize) {
setState(() {
Expand All @@ -35,7 +36,10 @@ class _HomePageState extends State<HomePage> {
article.data.content = "加载中";
article.starred = false;
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(article.data.title),
Expand Down Expand Up @@ -134,4 +138,3 @@ class _HomePageState extends State<HomePage> {
}



0 comments on commit a03e800

Please sign in to comment.