Work about PagedList history with infinite scroll

This commit is contained in:
poka 2020-12-18 23:54:43 +01:00
parent 1c26298a16
commit 5c4a029674
17 changed files with 183 additions and 2 deletions

BIN
assets/icon/gecko5b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
assets/icon/gecko5b36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/icon/gecko5b96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

1
lib/functions.dart Normal file
View File

@ -0,0 +1 @@

View File

@ -11,6 +11,8 @@ import 'package:intl/intl.dart';
import 'api.dart';
import "package:dio/dio.dart";
List<String> litems = ["1", "2", "Third", "4"];
void main() {
runApp(MyApp());
}
@ -96,7 +98,9 @@ class _MyAppState extends State<MyApp> {
),
style: TextStyle(
fontSize: 30.0, color: Colors.black)),
TextField(
// Affichage history
enabled: false,
controller: this._outputHistory,
@ -137,6 +141,11 @@ class _MyAppState extends State<MyApp> {
],
),
),
// new ListView.builder(
// itemCount: litems.length,
// itemBuilder: (BuildContext ctxt, int index) {
// return new Text(litems[index]);
// })
],
);
},
@ -270,4 +279,5 @@ class _MyAppState extends State<MyApp> {
// print("Veuillez renseigner une clé publique");
// }
// }
}

View File

@ -0,0 +1,12 @@
import 'package:flutter/cupertino.dart';
// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart';
/// Indicates that no items were found.
class EmptyListIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) => const ExceptionIndicator(
title: 'Too much filtering',
message: 'We couldn\'t find any results matching your applied filters.',
assetName: 'assets/empty-box.png',
);
}

View File

@ -0,0 +1,28 @@
import 'dart:io';
import 'package:flutter/material.dart';
// import 'package:readwenderlich/ui/exception_indicators/generic_error_indicator.dart';
// import 'package:readwenderlich/ui/exception_indicators/no_connection_indicator.dart';
/// Based on the received error, displays either a [NoConnectionIndicator] or
/// a [GenericErrorIndicator].
class ErrorIndicator extends StatelessWidget {
const ErrorIndicator({
@required this.error,
this.onTryAgain,
Key key,
}) : assert(error != null),
super(key: key);
final dynamic error;
final VoidCallback onTryAgain;
@override
Widget build(BuildContext context) => error is SocketException
? NoConnectionIndicator(
onTryAgain: onTryAgain,
)
: GenericErrorIndicator(
onTryAgain: onTryAgain,
);
}

View File

@ -0,0 +1,70 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Basic layout for indicating that an exception occurred.
class ExceptionIndicator extends StatelessWidget {
const ExceptionIndicator({
@required this.title,
@required this.assetName,
this.message,
this.onTryAgain,
Key key,
}) : assert(title != null),
assert(assetName != null),
super(key: key);
final String title;
final String message;
final String assetName;
final VoidCallback onTryAgain;
@override
Widget build(BuildContext context) => Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 16),
child: Column(
children: [
Image.asset(
assetName,
),
const SizedBox(
height: 32,
),
Text(
title,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
if (message != null)
const SizedBox(
height: 16,
),
if (message != null)
Text(
message,
textAlign: TextAlign.center,
),
if (onTryAgain != null) const Spacer(),
if (onTryAgain != null)
SizedBox(
height: 50,
width: double.infinity,
child: RaisedButton.icon(
onPressed: onTryAgain,
icon: const Icon(
Icons.refresh,
color: Colors.white,
),
label: const Text(
'Try Again',
style: TextStyle(
fontSize: 16,
color: Colors.white,
),
),
),
),
],
),
),
);
}

View File

@ -0,0 +1,21 @@
import 'package:flutter/cupertino.dart';
// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart';
/// Indicates that an unknown error occurred.
class GenericErrorIndicator extends StatelessWidget {
const GenericErrorIndicator({
Key key,
this.onTryAgain,
}) : super(key: key);
final VoidCallback onTryAgain;
@override
Widget build(BuildContext context) => ExceptionIndicator(
title: 'Something went wrong',
message: 'The application has encountered an unknown error.\n'
'Please try again later.',
assetName: 'assets/confused-face.png',
onTryAgain: onTryAgain,
);
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/cupertino.dart';
// import 'package:readwenderlich/ui/exception_indicators/exception_indicator.dart';
/// Indicates that a connection error occurred.
class NoConnectionIndicator extends StatelessWidget {
const NoConnectionIndicator({
Key key,
this.onTryAgain,
}) : super(key: key);
final VoidCallback onTryAgain;
@override
Widget build(BuildContext context) => ExceptionIndicator(
title: 'No connection',
message: 'Please check internet connection and try again.',
assetName: 'assets/frustrated-face.png',
onTryAgain: onTryAgain,
);
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -179,6 +179,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
infinite_scroll_pagination:
dependency: "direct main"
description:
name: infinite_scroll_pagination
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.3"
intl:
dependency: "direct main"
description:
@ -254,6 +261,13 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
sliver_tools:
dependency: transitive
description:
name: sliver_tools
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.10+1"
source_span:
dependency: transitive
description:
@ -326,4 +340,4 @@ packages:
version: "2.2.1"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
flutter: ">=1.22.0 <2.0.0"

View File

@ -33,11 +33,13 @@ dependencies:
gql_link:
intl:
flutter_launcher_icons: "^0.8.0"
infinite_scroll_pagination: ^2.2.3
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/gecko-bb-36.png"
image_path: "assets/icon/gecko5b96.png"
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.