32 lines
881 B
Dart
32 lines
881 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:riverpod_flutter_tuts/outerapi/auth/call/getRandomData.dart';
|
|
|
|
import '../../outerapi/auth/model/my_random.dart';
|
|
|
|
|
|
/// The homepage of our application
|
|
class RandomWidget extends StatelessWidget {
|
|
const RandomWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer(
|
|
builder: (context, ref, child) {
|
|
|
|
final AsyncValue<MyRandom> myRandom = ref.watch(getMyRandomProvider);
|
|
|
|
return Center(
|
|
child: switch (myRandom) {
|
|
AsyncData(:final MyRandom value ) => Text(
|
|
'myRandom: ${value}'
|
|
),
|
|
AsyncError() => const Text('Oops, something unexpected happened'),
|
|
_ => const CircularProgressIndicator(),
|
|
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
} |