Button overflow in ListView - dart

I have a basic Listview with a FlatButton as one of its children. When the button text is very large it overflows. See image.
How can I handle the overflow with ellipsis (or something else)?
Here's the build function:
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
FlatButton.icon(
color: Colors.grey[200],
onPressed: () {},
icon: Icon(Icons.tune, color: Colors.grey),
label: Text(
'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do ei',
maxLines: 1,
overflow: TextOverflow.ellipsis,
))
],
));
}

You could just wrap your Text widget in an Expanded widget.
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
FlatButton.icon(
color: Colors.grey[200],
onPressed: () {},
icon: Icon(Icons.tune, color: Colors.grey),
label: Expanded(
child: Text(
'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do ei',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
))
],
));
}

You Need to Wrap your few Widgets With Flexible Widget -
Code:
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Row(
children: <Widget>[
Flexible(
child: FlatButton.icon(
color: Colors.grey[200],
onPressed: () {},
icon: Icon(Icons.tune, color: Colors.grey),
label: Flexible(
child: Text(
'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do ei',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
)),
),
],
)
],
));

Related

Flutter I want to design the interface like this, can you guys help me? I am designing an about page but I am having problems

I have just learned and fluttered and am trying to design an about page. I am having difficulty in the card of flutter. I need a complete demo board to refer to the next issue.
You can use package expandable
full code
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Expandable Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
State createState() {
return MyHomePageState();
}
}
class MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("About DTC"),
),
body: ListView(
children: <Widget>[
Text(
loremIpsum,
softWrap: true,
overflow: TextOverflow.fade,
),
Card1(),
Card2(),
],
),
);
}
}
const loremIpsum =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
class Card1 extends StatelessWidget {
#override
Widget build(BuildContext context) {
return ExpandableNotifier(
child: ScrollOnExpand(
scrollOnExpand: false,
scrollOnCollapse: true,
child: Padding(
padding: const EdgeInsets.all(10),
child: Card(
clipBehavior: Clip.antiAlias,
child: Column(
children: <Widget>[
ScrollOnExpand(
scrollOnExpand: true,
scrollOnCollapse: false,
child: ExpandablePanel(
tapHeaderToExpand: true,
tapBodyToCollapse: true,
headerAlignment: ExpandablePanelHeaderAlignment.center,
header: Padding(
padding: EdgeInsets.all(10),
child: Text(
"Service",
style: Theme.of(context).textTheme.body2,
)),
collapsed:
Container(), //Text('Service', softWrap: true, maxLines: 2, overflow: TextOverflow.ellipsis,),
expanded: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
),
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
)
],
),
Row(
children: <Widget>[
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
),
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
)
],
),
Row(
children: <Widget>[
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
),
Expanded(
child: Column(children: <Widget>[
ListTile(title: Text('Item ')),
]),
)
],
),
],
),
builder: (_, collapsed, expanded) {
return Padding(
padding: EdgeInsets.only(left: 1, right: 1, bottom: 1),
child: Expandable(
collapsed: collapsed,
expanded: expanded,
crossFadePoint: 0,
),
);
},
),
),
],
),
),
),
));
}
}
class Card2 extends StatelessWidget {
#override
Widget build(BuildContext context) {
return ExpandableNotifier(
child: ScrollOnExpand(
scrollOnExpand: false,
scrollOnCollapse: true,
child: Padding(
padding: const EdgeInsets.all(10),
child: Card(
clipBehavior: Clip.antiAlias,
child: Column(
children: <Widget>[
ScrollOnExpand(
scrollOnExpand: true,
scrollOnCollapse: false,
child: ExpandablePanel(
tapHeaderToExpand: true,
tapBodyToCollapse: true,
headerAlignment: ExpandablePanelHeaderAlignment.center,
header: Padding(
padding: EdgeInsets.all(10),
child: Text(
"Contact",
style: Theme.of(context).textTheme.body2,
)),
collapsed:
Container(), //Text("Contact", softWrap: true, maxLines: 2, overflow: TextOverflow.ellipsis,),
expanded: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 10),
child: Text(
'Address : 5F',
softWrap: true,
overflow: TextOverflow.fade,
)),
],
),
builder: (_, collapsed, expanded) {
return Padding(
padding: EdgeInsets.only(left: 1, right: 1, bottom: 1),
child: Expandable(
collapsed: collapsed,
expanded: expanded,
crossFadePoint: 0,
),
);
},
),
),
],
),
),
),
));
}
}

How do I remove a child that's been pressed from ListView

I have a ListView in which I will dynamically add in some children of same type. Inside every children widget has a button. What I want to implement is, that, when user presses the button on a child widget, this child widget will be removed from the ListView. I can do this in C# using events, but I'm a total noob to Dart and Flutter.
Here is my ListView
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text('Edit Plan'),
backgroundColor: Colors.green,
actions: <Widget>[
Builder(
builder: (context) => IconButton(
icon: Icon(Icons.add),
onPressed: () {
setState(() {
txts.add('set');
});
},
),
)
],
),
backgroundColor: Colors.white,
body: ListView(
children: txts.map((string) =>
new ListViewItem()).toList(growable: false),
),
);
}
And here is my listViewItem:
class ListViewItem extends StatelessWidget {
final Workout workout;
ListViewItem({Key key, #required this.workout})
: assert(workout != null),
super(key: key);
#override
Widget build(BuildContext context) {
// TODO: implement build
final theme = Theme.of(context);
return Padding(
padding: EdgeInsets.all(12),
child: Card(
elevation: 12,
color: Colors.green,
child: Padding(
padding: EdgeInsets.only(top: 4, bottom: 4, left: 8, right: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(Icons.album),
title: Text(
'The Enchanted Nightingale',
style: TextStyle(color: Colors.white),
),
subtitle: Text(
'Music by Julie Gable. Lyrics by Sidney Stein.',
style: TextStyle(color: Colors.white),
),
),
TextFormField(
decoration: InputDecoration(
labelText: 'Name your workout',
labelStyle: TextStyle(color: Colors.white)),
),
ButtonTheme.bar(
// make buttons use the appropriate styles for cards
child: ButtonBar(
children: <Widget>[
FlatButton(
child: const Text(
'DELETE',
style: TextStyle(color: Colors.white),
),
onPressed: () {},
),
],
),
),
],
),
)),
);
}
}
I edited your code to use a ListView.builder, you need to remove the item at index from the List (txts) you are using, your code will be as follows:
List<String> txts = List();
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Edit Plan'),
backgroundColor: Colors.green,
actions: <Widget>[
Builder(
builder: (context) =>
IconButton(
icon: Icon(Icons.add),
onPressed: () {
setState(() {
txts.add('set');
});
},
),
)
],
),
backgroundColor: Colors.white,
body: new ListView.builder(
itemCount: txts.length,
itemBuilder: (BuildContext context, int index) {
return ListViewItem(
workout: workout,
onDelete: (){
setState(() {
txts.removeAt(index);
});
},
);
},
),
);
}
in addition to that you need to add an ondelete callback in the ListViewItem, the code in the ListViewItem class will be as follows:
class ListViewItem extends StatelessWidget {
final Workout workout;
final VoidCallback onDelete;
ListViewItem({Key key, #required this.workout, this.onDelete})
: assert(workout != null),
super(key: key);
#override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: EdgeInsets.all(12),
child: Card(
elevation: 12,
color: Colors.green,
child: Padding(
padding: EdgeInsets.only(top: 4, bottom: 4, left: 8, right: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(Icons.album),
title: Text(
'The Enchanted Nightingale',
style: TextStyle(color: Colors.white),
),
subtitle: Text(
'Music by Julie Gable. Lyrics by Sidney Stein.',
style: TextStyle(color: Colors.white),
),
),
TextFormField(
decoration: InputDecoration(
labelText: 'Name your workout',
labelStyle: TextStyle(color: Colors.white)),
),
ButtonTheme.bar(
// make buttons use the appropriate styles for cards
child: ButtonBar(
children: <Widget>[
FlatButton(
child: const Text(
'DELETE',
style: TextStyle(color: Colors.white),
),
onPressed: () =>onDelete(),
),
],
),
),
],
),
)),
);
}
}

Flutter how to get subtext aligned under title in appbar?

I have the following app bar in flutter and trying to align the subtext "Your desired business name" under the title enter. I have tried different methods but still can't get to align. It should have "enter" at the top and then the subtext aligned center
Here is my current code
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(75.0),
child: AppBar(
centerTitle: true,
title: Text('enter'),
actions: <Widget>[
new Container(),
new Center(
child: Text(
'Your desired business name',
textAlign: TextAlign.center,
style: new TextStyle(
fontSize: 14.0,
color: Colors.white,
),
)),
],
)),
);
}
To align Text under AppBar title you can use bottom property of AppBar which takes PreferredSize widget as a parameter which also helps you to adjust the height of AppBar according to your need.
Here's the code
AppBar(
title: Text('Title 1'),
centerTitle: true,
bottom: PreferredSize(
child: Text("Title 2"),
preferredSize: Size.zero),
)
The menu bar actions widgets get aligned on the right and as far as I know it is not possible to obtain your desidered layout.
Should you consider a column based widget with a title and subtitle:
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
centerTitle: true,
title: Column(children: [
Text(
"Title",
),
GestureDetector(
child: Text('subtitle'),
onTap: () {
print("tapped subtitle");
},
)
]),
...
In this example there is a GestureDetector for give interactivity to subtitle, since it seems it is what you are trying to do.
I am using this code for adding subtitle and show UserIcon
//name,status and userPic are variable's
#override
Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
title: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
Text(
status,
style: TextStyle(color: Colors.white, fontSize: 14.0),
)
],
),
leading: new Padding(
padding: const EdgeInsets.all(5.0),
child: new CircleAvatar(
backgroundImage: new NetworkImage(userPicUrl),
),
),
actions: <Widget>[new Icon(Icons.more_vert)],
),
);
}
Output
You should add Column view.
title: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Title",
style: TextStyle(color: Colors.white, fontSize: 16.0),
),
Text(
"Sub Title",
style: TextStyle(color: Colors.white, fontSize: 14.0),
),
]
),
In these cases I prefer to use a ListTile:
#override
Widget build(BuildContext context) {
return Scaffold(
appBar:
AppBar(
title:
ListTile(
title:
Text("Enter", style: TextStyle(color:Colors.white)),
subtitle:
Text("Your desired business name", style: TextStyle(color:Colors.white)),
)
),
);
}
If you need the Text widget centered just wrap it within a Center widget.
The answer in https://stackoverflow.com/a/53880971/9185192 works but with null safety landing in Dart it is not allowed to set preferredSize to null.
So the solution is to set preferredSize to zero or any other valid number.
appBar: AppBar(
title: Text('Title 1'),
centerTitle: true,
bottom: PreferredSize(
child: Text("Title 2"),
preferredSize: Size.fromHeight(0),
),
)
appBar: AppBar(
title: Center(
child: Text('Flutter Tutorial'),
),

Flutter align widgets in an expanded container, to the top left and bottom right?

I have a layout in my application which comprises of some text and a timestamp. I'm looking to have the timestamp (clock icon in the picture) be at the bottom left corner of the expanded widget, while the text ("what" string in the picture) should start from the top right.
Representation:
|text| |
| ----------- |
| empty space |
| ----------- |
| |time|
Currently, what I managed below have them aligned to the extreme left and right, but they seem to be constrained by the Column widget and as such, are aligned to the centre of the widget. And I cannot seem to get expanded to work within another Expanded.
Widget code:
return new Container(
child: new Row(
children: <Widget>[
new Column(
children: <Widget>[
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.keyboard_arrow_up),
onPressed: () => null,
),
new Container(
padding: new EdgeInsets.all(5.0),
child: new Text("1231"),
),
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.keyboard_arrow_down),
onPressed: () => null,
),
],
),
new Expanded(
// child: new Container(
// padding: EdgeInsets.all(10.0),
child: new Column(
// mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Align(
alignment: Alignment.topLeft,
child: new Text("what"),
),
// "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."),
new Align(
// padding: new EdgeInsets.all(10.0),
alignment: Alignment.bottomRight,
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Container(
padding: new EdgeInsets.all(2.0),
child: new Icon(
Icons.access_time,
size: 12.0,
),
),
new Container(
padding: new EdgeInsets.all(2.0),
child: new Text("1 hr"),
),
],
),
),
],
),
// ),
),
new Column(
children: <Widget>[
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.save, size: 20.0),
onPressed: () => null,
),
new Container(
padding: new EdgeInsets.all(5.0),
child: new Text("8"),
),
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.comment, size: 20.0),
onPressed: () => null,
),
],
),
],
),
);
}
try using alignment: Alignment.bottomRight as a named parameter of Container class
Ok, so I modified your Widget and I added some Colors to the container to track the changes very easy:
double maxHeight = 130.0;
Widget _buildLeft() {
return Container(
height: maxHeight,
color: Colors.red,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.keyboard_arrow_up),
onPressed: () => null,
),
new Container(
padding: new EdgeInsets.all(5.0),
child: new Text("1231"),
),
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.keyboard_arrow_down),
onPressed: () => null,
),
],
),
);
}
Widget _buildCenter() {
return Expanded(
child: Container(
height: maxHeight,
color: Colors.blue,
child: Stack(
children: <Widget>[
Positioned(
child: new Text("what"),
top: 0.0,
left: 0.0,
),
// "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."),
Positioned(
bottom: 0.0,
right: 0.0,
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Container(
padding: new EdgeInsets.all(2.0),
child: new Icon(
Icons.access_time,
size: 12.0,
),
),
new Container(
padding: new EdgeInsets.all(2.0),
child: new Text("1 hr"),
),
],
),
),
],
),
),
);
}
Widget _buildRight() {
return Container(
height: maxHeight,
color: Colors.green,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.save, size: 20.0),
onPressed: () => null,
),
new Container(
padding: new EdgeInsets.all(5.0),
child: new Text("8"),
),
new MaterialButton(
minWidth: 60.0,
child: new Icon(Icons.comment, size: 20.0),
onPressed: () => null,
),
],
),
);
}
#override
Widget build(BuildContext context) {
return new Container(
child: new Row(
children: <Widget>[
_buildLeft(),
_buildCenter(),
_buildRight(),
],
),
);
}
You can use a Container wrap the Align, This can stop Align from expanding itself
Container(
color: darkBlue,
child: Align(
alignment: Alignment.center,
heightFactor: value,
child: Container(
// alignment: Alignment.center, //<--must not uncomment this
padding: const EdgeInsets.all(16),
color: Colors.red,
child: child,
),
),
)

Creating a Sticky Site Footer

I have not been able to locate any documentation for creating footer nav bars with Flutter/Dart. I know that "crossAxisAlignment: CrossAxisAlignment.end" can be used to pull content to the bottom of a column. However, I'm not sure how to render a site footer that sticks to the bottom of the screen. There are various solutions in flex and css grid, but not clear on what implementation would look like in this platform.
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
Widget siteLogo = new Container(
padding: const EdgeInsets.only(top: 100.0),
child: new Image.asset(
'images/logo.png',
width: 180.0,
height: 180.0,
),
);
Widget titleTextSection = new Container(
padding: const EdgeInsets.only(left: 80.0, right: 80.0, top: 30.0, bottom: 20.0),
child: new Text(
''' Welcome to The Site''',
textAlign: TextAlign.center,
style: new TextStyle(
fontSize: 35.0,
fontWeight: FontWeight.w500,
),
),
);
Widget subtitleTextSection = new Container(
padding: const EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
child: new Text(
'''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec imperdiet Donec imperdiet.''',
textAlign: TextAlign.center,
style: new TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.w400
),
),
);
// footer
Column signInLink(String label) {
return new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Container(
child: new Text(
label,
style: new TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: const Color(0xFFf735e9)
),
),
),
],
);
}
Column existingAccountLink(String label) {
return new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Container(
child: new Text(
label,
style: new TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: const Color(0xFFeceff1)
),
),
),
],
);
}
Widget footer = new Container(
height: 50.0,
decoration: new BoxDecoration(color: Colors.black),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
existingAccountLink('Already have an account?'),
signInLink('SIGN IN'),
],
),
);
return new MaterialApp(
title: 'Flutter Demo',
home: new Scaffold(
body: new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage('images/backgroundimg.jpg'),
fit: BoxFit.cover,
),
),
child: new ListView(
children: [
siteLogo,
titleTextSection,
subtitleTextSection,
footer,
],
),
)
),
);
}
}
As you can see, I am currently using ListView to layout the widgets. The only thing I can think of right now is to put the whole ListView in a single column, crossAxisAlign to End so everything gets pulled down, and then style each widget relative to the footer. There must be a better way though?
Since you are using Scaffold, you can use bottomNavigationBar to have a 'sticky' bottom widget. (And potentially use BottomNavigationBar if you want to)
new Scaffold(
appBar: new AppBar(title: new Text("Title")),
body: new ListView.builder(
itemBuilder: (context, index) {
return new ListTile(
title: new Text("title $index"),
);
},
),
bottomNavigationBar: new Container(
height: 40.0,
color: Colors.red,
),
);
Alternatively your
The only thing I can think of right now is to put the whole ListView in a single column
is not a bad idea at all. That's how things works in flutter.
Although MainAxisAlignement.end is not the right way to do it.
You could achieve the same layout as with bottomNavigationBar without a Scaffold, using a Column this way :
new Column(
children: <Widget>[
new Expanded(
child: new ListView.builder(
itemBuilder: (context, index) {
return new ListTile(
title: new Text("title $index"),
);
},
),
),
new Container(
height: 40.0,
color: Colors.red,
),
],
),
The use of a listview is an excellent choice when you have a list of items that need a listview. Sometimes the other items in the layout might be fixed and do not need a listview. e.g using a column.
Example on how to achieve fixed bottom footer using stack.
#override
Widget build(BuildContext context) {
return new Material(
child: Scaffold(
body: Stack(
children : <Widget> [
Text("Top positioned text"),
Column(
children : <Widget> [
Text("Column:Top positioned text"),
Text("Column:Top positioned text")
]
),
Positioned(
bottom : 0,
child: Text("Bottom positioned text")
)
]
)
}
you can use Footer from flutter_layouts
sticky footer can be hard to implement. since you have to know the height of footer, it is not possible to perform this in build() function.
try out below flutter package.
https://github.com/softmarshmallow/flutter-layouts/tree/master/lib/src/footer
https://github.com/softmarshmallow/flutter-layouts/
by this, you can use footer with scaffold bottom nav. example
import 'package:flutter_layouts/flutter_layouts.dart';
class _FooterScreenState extends State<FooterScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("footer demo"),
),
body: buildBody(),
bottomNavigationBar: BottomNavigationBar(items: [
BottomNavigationBarItem(icon: Icon(Icons.add), title: Text("first")),
BottomNavigationBarItem(icon: Icon(Icons.remove), title: Text("second"))
]),
);
}
Widget buildBody() {
return Footer(
body: buildContent(),
footer: buildFooter(),
);
}
Widget buildContent() {
return ListView.builder(
itemBuilder: (c, i) {
return Card(
margin: EdgeInsets.all(16),
child: Container(
padding: EdgeInsets.all(24),
child: Text("contents"),
),
);
},
itemCount: 20,
);
}
Widget buildFooter() {
return Container(
padding: EdgeInsets.all(24),
decoration: BoxDecoration(color: Theme.of(context).primaryColor),
child: FlatButton(
onPressed: () {},
child: Text("Lean more", style: Theme.of(context).textTheme.button.copyWith(
color: Theme.of(context).colorScheme.onBackground
),),
),
);
}
}

Resources