Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added how to create CustomLoadMoreDelegate for devs in the readme #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,82 @@ abstract class LoadMoreDelegate {
}
```

create your CustomLoadMoreDelegate:

```dart
class CustomLoadMoreDelegate extends LoadMoreDelegate {
const CustomLoadMoreDelegate();

@override
Widget buildChild(LoadMoreStatus status,
{LoadMoreTextBuilder builder = DefaultLoadMoreTextBuilder.english}) {
String text = builder(status);
if (status == LoadMoreStatus.fail) {
return Text(
'Failed to load data',
style: TextStyle(
color: Colors.red,
fontSize: 16.0
),
);
}
if (status == LoadMoreStatus.idle) {
return Text(
'Idle',
style: TextStyle(
color: Colors.blue,
fontSize: 16.0
),
);
}
if (status == LoadMoreStatus.loading) {
return Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 20.0,
height: 20.0,
child: const CircularProgressIndicator(
backgroundColor: Colors.green,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Loading....',
style: TextStyle(
color: Colors.blue,
fontSize: 16.0
),
)
),
],
),
);
}
if (status == LoadMoreStatus.nomore) {
return Text(
'No more data fetched',
style: TextStyle(
color: Colors.blue,
fontSize: 16.0
),
);
}

return Text(
text,
style: TextStyle(
color: Colors.blue,
fontSize: 16.0
),
);
}
}
```

## other

homePage: https://github.com/CaiJingLong/flutter_listview_loadmore
Expand Down