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
|
// For widgets to be able to read providers, we need to wrap the entire
|
||||||
// application in a "ProviderScope" widget.
|
// application in a "ProviderScope" widget.
|
||||||
// This is where the state of our providers will be stored.
|
// This is where the state of our providers will be stored.
|
||||||
ProviderScope(
|
const ProviderScope(
|
||||||
child: MyApp(),
|
child: MyApp(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -26,6 +26,8 @@ void main() {
|
|||||||
|
|
||||||
// Extend ConsumerWidget instead of StatelessWidget, which is exposed by Riverpod
|
// Extend ConsumerWidget instead of StatelessWidget, which is exposed by Riverpod
|
||||||
class MyApp extends ConsumerWidget {
|
class MyApp extends ConsumerWidget {
|
||||||
|
const MyApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final String value = ref.watch(helloWorldProvider);
|
final String value = ref.watch(helloWorldProvider);
|
||||||
@ -36,9 +38,9 @@ class MyApp extends ConsumerWidget {
|
|||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(child: Text('1')),
|
const Expanded(child: Text('1')),
|
||||||
Expanded(child: Text(value)),
|
Expanded(child: Text(value)),
|
||||||
Expanded(child: RandomWidget())
|
const Expanded(child: RandomWidget())
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
// GET http://localhost:3000/p/random
|
// GET http://localhost:3000/p/random
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import '../model/my_random.dart';
|
import '../model/my_random.dart';
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class RandomWidget extends StatelessWidget {
|
|||||||
return Center(
|
return Center(
|
||||||
child: switch (myRandom) {
|
child: switch (myRandom) {
|
||||||
AsyncData(:final MyRandom value ) => Text(
|
AsyncData(:final MyRandom value ) => Text(
|
||||||
'myRandom: ${value}'
|
'myRandom: $value'
|
||||||
),
|
),
|
||||||
AsyncError() => const Text('Oops, something unexpected happened'),
|
AsyncError() => const Text('Oops, something unexpected happened'),
|
||||||
_ => const CircularProgressIndicator(),
|
_ => const CircularProgressIndicator(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user