Files
Remi Rousselet a54f32fec6 Enable translating code snippets without cloning them (#3335)
We have way too many duplicates of the same code snippets.

This makes migrating code to newer versions difficult, as lots of clones
need to be updated.

Let's remove duplicates by enabling translation of comments inside
snippets
2024-02-11 16:27:22 +01:00

28 lines
777 B
Dart

// ignore_for_file: unused_local_variable, avoid_multiple_declarations_per_line, omit_local_variable_types, prefer_final_locals, use_key_in_widget_constructors
import 'package:flutter_riverpod/flutter_riverpod.dart';
class User {
late String firstName, lastName;
}
final userProvider = FutureProvider(
(ref) => User()
..firstName = 'John'
..lastName = 'Doe',
);
/* SNIPPET START */
final provider = FutureProvider((ref) async {
// {@template watch}
// Wait for a user to be available, and listen to only the "firstName" property
// {@endtemplate}
final firstName = await ref.watch(
userProvider.selectAsync((it) => it.firstName),
);
// {@template todo}
// TODO use "firstName" to fetch something else
// {@endtemplate}
});
/* SNIPPET END */