1
0
forked from firka/firka
Files
firka/firka_wear/lib/helpers/ui/stateless_async_widget.dart
Armand ad90b8baa0 wear: initial commit
based on 549b7e3e11
with some parts removed, and some parts backported
from the latest commit
2025-08-27 17:01:13 +02:00

24 lines
776 B
Dart

import 'package:firka_wear/ui/widget/delayed_spinner.dart';
import 'package:flutter/material.dart';
abstract class StatelessAsyncWidget extends StatelessWidget {
const StatelessAsyncWidget({super.key});
Future<Widget> buildAsync(BuildContext context);
@override
Widget build(BuildContext context) {
return FutureBuilder<Widget>(
future: buildAsync(context),
builder: (BuildContext context, AsyncSnapshot<Widget> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: DelayedSpinnerWidget());
} else if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
} else {
return snapshot.data!;
}
});
}
}