Compare commits

..

No commits in common. "d44fc9a75c88a6bb6e87b87dd25050833d93bf53" and "93d55d07715025bb0150b2e02bbe3550e4a139cc" have entirely different histories.

3 changed files with 5 additions and 6 deletions

View File

@ -18,7 +18,7 @@ void main() {
// For widgets to be able to read providers, we need to wrap the entire
// application in a "ProviderScope" widget.
// This is where the state of our providers will be stored.
const ProviderScope(
ProviderScope(
child: MyApp(),
),
);
@ -26,8 +26,6 @@ void main() {
// Extend ConsumerWidget instead of StatelessWidget, which is exposed by Riverpod
class MyApp extends ConsumerWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final String value = ref.watch(helloWorldProvider);
@ -38,9 +36,9 @@ class MyApp extends ConsumerWidget {
body: Center(
child: Column(
children: <Widget>[
const Expanded(child: Text('1')),
Expanded(child: Text('1')),
Expanded(child: Text(value)),
const Expanded(child: RandomWidget())
Expanded(child: RandomWidget())
],
)

View File

@ -2,6 +2,7 @@
// GET http://localhost:3000/p/random
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../model/my_random.dart';

View File

@ -19,7 +19,7 @@ class RandomWidget extends StatelessWidget {
return Center(
child: switch (myRandom) {
AsyncData(:final MyRandom value ) => Text(
'myRandom: $value'
'myRandom: ${value}'
),
AsyncError() => const Text('Oops, something unexpected happened'),
_ => const CircularProgressIndicator(),