mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-06-07 22:22:42 -04:00
more refactor
This commit is contained in:
parent
b83aa3a64b
commit
c7b541c643
45 changed files with 860 additions and 336 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
import 'package:blurry_modal_progress_hud/blurry_modal_progress_hud.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:motion_toast/motion_toast.dart';
|
||||
|
@ -60,6 +61,22 @@ extension AsyncValueBuilderExt<T> on AsyncValue<T> {
|
|||
asyncValueBuilder<T>(this, builder);
|
||||
}
|
||||
|
||||
class AsyncBlocBuilder<B extends StateStreamable<AsyncValue<S>>, S>
|
||||
extends BlocBuilder<B, AsyncValue<S>> {
|
||||
AsyncBlocBuilder({
|
||||
required BlocWidgetBuilder<S> builder,
|
||||
Widget Function(BuildContext)? loading,
|
||||
Widget Function(BuildContext, Object, StackTrace?)? error,
|
||||
super.key,
|
||||
super.bloc,
|
||||
super.buildWhen,
|
||||
}) : super(
|
||||
builder: (context, state) => state.when(
|
||||
loading: () => (loading ?? waitingPage)(context),
|
||||
error: (e, st) => (error ?? errorPage)(context, e, st),
|
||||
data: (d) => builder(context, d)));
|
||||
}
|
||||
|
||||
Future<void> showErrorModal(
|
||||
BuildContext context, String title, String text) async {
|
||||
await QuickAlert.show(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue