xxxxxxxxxx
SingleChildScrollView(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
width: 1000, // Adjust the width based on your content
child: // Your content here
),
),
scrollDirection: Axis.vertical,
)
xxxxxxxxxx
SingleChildScrollView
Column
Container
ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
//...
)
xxxxxxxxxx
final _scrollController = ScrollController();
@override
void initState() {
_scrollController.addListener(() {
if (_scrollController.position.maxScrollExtent == _scrollController.offset) {
_loadMore();
}
});
HttpOverrides.global = MwHttpOverrides();
_loadMore();
}
SingleChildScrollView(
controller: _scrollController,
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: count + 1, // list.length + 1
itemBuilder: (BuildContext context, int index) => (index != count)
? Text("Your List Item"),
: LoadMoreWidget(_loadMoreStatus),
},
),
),
//// load_more.dart
enum LoadMoreStatus {
/// the view is loading
loading,
/// loading fail, need tap view to loading
fail,
/// not have more data
nomore,
// data loaded
done,
}
String _buildPersianText(LoadMoreStatus status) {
String text;
switch (status) {
case LoadMoreStatus.fail:
text = "error";
break;
case LoadMoreStatus.loading:
text = "Loading, please wait...";
break;
case LoadMoreStatus.nomore:
text = "no more data";
break;
default:
text = "";
}
return text;
}
class LoadMoreWidget extends StatelessWidget {
LoadMoreWidget(this.status);
final status;
@override
Widget build(BuildContext context) {
String text = _buildPersianText(status);
if (status == LoadMoreStatus.fail) {
return Container(
height: 50,
alignment: Alignment.center,
child: Text(text),
);
}
if (status == LoadMoreStatus.idle) {
return Container(
height: 50,
alignment: Alignment.center,
child: Text(text),
);
}
if (status == LoadMoreStatus.loading) {
return Container(
height: 50,
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 25,
height: 25,
child: CircularProgressIndicator(
backgroundColor: Colors.white,
),
),
SizedBox(
width: 16.0,
),
Text(text),
],
),
);
}
if (status == LoadMoreStatus.nomore) {
return Container(
height: 50,
alignment: Alignment.center,
child: Text(text),
);
}
return Container(
height: 50,
alignment: Alignment.center,
child: Text(text),
);
}
}
xxxxxxxxxx
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AppBar'),
),
body: LayoutBuilder(builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth, minHeight: constraints.maxHeight),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Text('header'),
Expanded(
child: Container(
color: Colors.green,
child: Text('body'),
),
),
Text('footer'),
]
),
)
)
);
})
);
}
}