Show an image if there is no data yet

This commit is contained in:
Ricardo Markiewicz
2019-07-02 09:52:09 -03:00
parent 5b3358ca6f
commit a9453903e8
2 changed files with 36 additions and 21 deletions
+34 -18
View File
@@ -117,12 +117,28 @@ class _HomePageState extends State<HomePage> {
stream: _query, stream: _query,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) { builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
if (data.hasData) { if (data.hasData) {
return MonthWidget( if (data.data.documents.length > 0) {
days: daysInMonth(currentPage + 1), return MonthWidget(
documents: data.data.documents, days: daysInMonth(currentPage + 1),
graphType: currentType, documents: data.data.documents,
month: currentPage, graphType: currentType,
); month: currentPage,
);
} else {
return Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('assets/no_data.png'),
SizedBox(height: 80),
Text(
"Add an expense to begin",
style: Theme.of(context).textTheme.caption,
)
],
),
);
}
} }
return Center( return Center(
@@ -183,18 +199,18 @@ class _HomePageState extends State<HomePage> {
}, },
controller: _controller, controller: _controller,
children: <Widget>[ children: <Widget>[
_pageItem("Enero", 0), _pageItem("January", 0),
_pageItem("Febrero", 1), _pageItem("February", 1),
_pageItem("Marzo", 2), _pageItem("March", 2),
_pageItem("Abril", 3), _pageItem("April", 3),
_pageItem("Mayo", 4), _pageItem("May", 4),
_pageItem("Junio", 5), _pageItem("June", 5),
_pageItem("Julio", 6), _pageItem("July", 6),
_pageItem("Agosto", 7), _pageItem("August", 7),
_pageItem("Septiembre", 8), _pageItem("September", 8),
_pageItem("Octubre", 9), _pageItem("October", 9),
_pageItem("Noviembre", 10), _pageItem("November", 10),
_pageItem("Diciembre", 11), _pageItem("December", 11),
], ],
), ),
); );
+2 -3
View File
@@ -49,9 +49,8 @@ flutter:
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: assets:
# - images/a_dot_burr.jpeg - assets/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware. # https://flutter.io/assets-and-images/#resolution-aware.