dreampad/lib/app/shared/helpers/deferred_router.dart
2023-11-28 10:45:09 +08:00

31 lines
708 B
Dart

import 'package:flutter/material.dart';
class DeferredRouter extends StatelessWidget {
const DeferredRouter({
Key? key,
required this.future,
required this.builder,
}) : super(key: key);
final Future future;
final WidgetBuilder builder;
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: future,
builder: (context, snapshot) {
// web scene
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
if (snapshot.connectionState != ConnectionState.done) {
return const Center(child: CircularProgressIndicator());
}
return builder(context);
},
);
}
}