11import 'package:flutter/material.dart' ;
22import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
3- import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
43import 'package:flutter_markdown/flutter_markdown.dart' ;
4+ import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
55import 'package:gsy_github_app_flutter/page/RepositoryDetailPage.dart' ;
66
77/**
@@ -17,13 +17,14 @@ class RepositoryDetailReadmePage extends StatefulWidget {
1717
1818 final BranchControl branchControl;
1919
20- RepositoryDetailReadmePage (this .userName, this .reposName, this .branchControl, { Key key }) : super (key: key);
20+ RepositoryDetailReadmePage (this .userName, this .reposName, this .branchControl, {Key key}) : super (key: key);
2121
2222 @override
2323 RepositoryDetailReadmePageState createState () => RepositoryDetailReadmePageState (userName, reposName, branchControl);
2424}
2525
26- class RepositoryDetailReadmePageState extends State <RepositoryDetailReadmePage > {
26+ // ignore: mixin_inherits_from_not_object
27+ class RepositoryDetailReadmePageState extends State <RepositoryDetailReadmePage > with AutomaticKeepAliveClientMixin {
2728 final String userName;
2829
2930 final String reposName;
@@ -32,7 +33,7 @@ class RepositoryDetailReadmePageState extends State<RepositoryDetailReadmePage>
3233
3334 bool isShow = false ;
3435
35- String markdownData = "" ;
36+ String markdownData;
3637
3738 RepositoryDetailReadmePageState (this .userName, this .reposName, this .branchControl);
3839
@@ -48,6 +49,9 @@ class RepositoryDetailReadmePageState extends State<RepositoryDetailReadmePage>
4849 });
4950 }
5051
52+ @override
53+ bool get wantKeepAlive => true ;
54+
5155 @override
5256 void initState () {
5357 isShow = true ;
@@ -63,10 +67,26 @@ class RepositoryDetailReadmePageState extends State<RepositoryDetailReadmePage>
6367
6468 @override
6569 Widget build (BuildContext context) {
70+ if (markdownData == null ) {
71+ return Center (
72+ child: new Container (
73+ width: 140.0 ,
74+ height: 140.0 ,
75+ padding: new EdgeInsets .all (4.0 ),
76+ child: new Row (
77+ mainAxisAlignment: MainAxisAlignment .center,
78+ children: < Widget > [
79+ new CircularProgressIndicator (),
80+ new Container (width: 10.0 ),
81+ new Container (child: new Text (GSYStrings .loading_text, style: GSYConstant .middleText)),
82+ ],
83+ ),
84+ ),
85+ );
86+ }
6687 return Container (
6788 child: SingleChildScrollView (
68- child: new MarkdownBody (data: markdownData),
69- )
70- );
89+ child: new MarkdownBody (data: markdownData),
90+ ));
7191 }
7292}
0 commit comments