Some lang fixes.
This commit is contained in:
parent
87ba800e54
commit
e846da176b
@ -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.
|
||||
ProviderScope(
|
||||
const ProviderScope(
|
||||
child: MyApp(),
|
||||
),
|
||||
);
|
||||
@ -26,6 +26,8 @@ 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);
|
||||
@ -36,9 +38,9 @@ class MyApp extends ConsumerWidget {
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(child: Text('1')),
|
||||
const Expanded(child: Text('1')),
|
||||
Expanded(child: Text(value)),
|
||||
Expanded(child: RandomWidget())
|
||||
const Expanded(child: RandomWidget())
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
// 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';
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user