I don't know why the dart compiler shows me an error in my code. What is that actually means? Thanks.
Source:
const SliverAppBar(
pinned: true,
expandedHeight: 300.0, // TODO: check out later
flexibleSpace: FlexibleSpaceBar(
title: new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text('_SliverAppBar'),
Text('subtitle'),
],
),
background: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Info'),
],
)),
I have commented the original answer that lead to that problem. But here is why:
As @aziza pointed, you have instantiated your SliverAppBar
with the const
keyword. Therefore, all properties should be instantiated with const
.
In your case, just changing from new Column
to const Column
would solve the problem, but, dart 2 can infer how it will instantiate the class. Just omit the new
and const
keywords, and let dart do the work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With