Skip to content

Commit

Permalink
Migrate to plain ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurogoma4D committed Oct 23, 2024
1 parent c60513c commit ed90a76
Show file tree
Hide file tree
Showing 76 changed files with 199 additions and 88 deletions.
3 changes: 2 additions & 1 deletion apps/app/lib/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:conference_2024_app/main_page.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'router.g.dart';
Expand All @@ -23,7 +24,7 @@ part 'routes/main/venue/venue_shell_branch.dart';
final _rootNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'root');

@Riverpod(keepAlive: true)
GoRouter router(RouterRef ref) {
GoRouter router(Ref ref) {
return GoRouter(
navigatorKey: _rootNavigatorKey,
routes: [
Expand Down
4 changes: 3 additions & 1 deletion apps/app/lib/routing/router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/ticket_web/lib/core/provider/environment.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// ignore_for_file: do_not_use_environment

import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'environment.g.dart';

@Riverpod(keepAlive: true, dependencies: [])
Environment environment(EnvironmentRef ref) =>
Environment.fromEnvironmentValues();
Environment environment(Ref ref) => Environment.fromEnvironmentValues();

class Environment {
const Environment._({
Expand Down
4 changes: 3 additions & 1 deletion apps/ticket_web/lib/core/provider/environment.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:image_picker_macos/image_picker_macos.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'image_picker_for_io.g.dart';

@Riverpod(keepAlive: true)
ImagePickerMacOS imagePicker(ImagePickerRef ref) => ImagePickerMacOS();
ImagePickerMacOS imagePicker(Ref ref) => ImagePickerMacOS();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:image_picker_for_web/image_picker_for_web.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'image_picker_for_web.g.dart';

@Riverpod(keepAlive: true)
ImagePickerPlugin imagePicker(ImagePickerRef ref) => ImagePickerPlugin();
ImagePickerPlugin imagePicker(Ref ref) => ImagePickerPlugin();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export './image_picker/image_picker_for_io.dart'
if (dart.library.js_interop) './image_picker/image_picker_for_web.dart'
show ImagePickerRef, imagePicker, imagePickerProvider;
show imagePicker, imagePickerProvider;
3 changes: 2 additions & 1 deletion apps/ticket_web/lib/core/provider/language_provider.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:collection/collection.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_web/core/provider/shared_preferences.dart';
import 'package:ticket_web/gen/i18n/strings.g.dart';

part 'language_provider.g.dart';

@Riverpod(keepAlive: true)
List<AppLocale> supportedLocales(SupportedLocalesRef ref) =>
List<AppLocale> supportedLocales(Ref ref) =>
LocaleSettings.instance.translationMap.keys.toList();

@Riverpod(keepAlive: true)
Expand Down
4 changes: 3 additions & 1 deletion apps/ticket_web/lib/core/provider/language_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/ticket_web/lib/core/provider/shared_preferences.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'shared_preferences.g.dart';

@Riverpod(keepAlive: true)
SharedPreferences sharedPreferences(SharedPreferencesRef ref) =>
throw UnimplementedError();
SharedPreferences sharedPreferences(Ref ref) => throw UnimplementedError();
4 changes: 3 additions & 1 deletion apps/ticket_web/lib/core/provider/shared_preferences.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/ticket_web/lib/core/router/router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_web/feature/auth/data/auth_notifier.dart';
import 'package:ticket_web/pages/debug/components/navigation_debug_page.dart';
Expand All @@ -12,7 +13,7 @@ import 'package:ticket_web/pages/verify_purchase/verify_purchase_page.dart';
part 'router.g.dart';

@Riverpod(keepAlive: true)
GoRouter router(RouterRef ref) {
GoRouter router(Ref ref) {
return GoRouter(
routes: $appRoutes,
debugLogDiagnostics: kDebugMode,
Expand Down
4 changes: 3 additions & 1 deletion apps/ticket_web/lib/core/router/router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/ticket_web/lib/feature/auth/data/auth_notifier.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:common_data/auth.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'on_auth_state_change_provider.g.dart';

@Riverpod(keepAlive: true)
Stream<AuthChangeEvent> onAuthStateChange(OnAuthStateChangeRef ref) =>
Stream<AuthChangeEvent> onAuthStateChange(Ref ref) =>
ref.watch(authRepositoryProvider).onAuthStateChange;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_web/core/provider/environment.dart';
import 'package:url_launcher/url_launcher.dart';

part 'payment_service.g.dart';

@Riverpod(keepAlive: true, dependencies: [environment])
PaymentService paymentService(PaymentServiceRef ref) {
PaymentService paymentService(Ref ref) {
return PaymentService(
environment: ref.watch(environmentProvider),
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ignore_for_file: do_not_use_environment

import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_web/feature/payment/data/model/payment_url.dart';

part 'payment_url_provider.g.dart';

@Riverpod(keepAlive: true)
PaymentUrl paymentUrl(PaymentUrlRef ref) {
PaymentUrl paymentUrl(Ref ref) {
const generalUrl = String.fromEnvironment('STRIPE_PAYMENT_GENERAL_URL');
const invitationUrl = String.fromEnvironment('STRIPE_PAYMENT_INVITATION_URL');
const personalSponsorUrl =
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'dart:typed_data';

import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_web/feature/profile/data/profile_notifier.dart';

part 'user_avatar_image_provider.g.dart';

@Riverpod(keepAlive: true)
Future<Uint8List?> userAvatarImage(UserAvatarImageRef ref) async {
Future<Uint8List?> userAvatarImage(Ref ref) async {
final profile = ref.watch(profileNotifierProvider);
return switch (profile) {
AsyncData(:final value) when value?.userAvatarFetch != null =>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:ticket_api/model/ticket/promotion_metadata.dart';
import 'package:ticket_api/ticket_api.dart';
Expand All @@ -6,7 +7,7 @@ import 'package:ticket_web/core/provider/environment.dart';
part 'promotion_code_service.g.dart';

@Riverpod(keepAlive: true, dependencies: [environment])
PromotionCodeService promotionCodeService(PromotionCodeServiceRef ref) {
PromotionCodeService promotionCodeService(Ref ref) {
final baseUrl = ref.watch(environmentProvider).ticketApiBaseUrl;

return PromotionCodeService(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:common_data/session.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'session_provider.g.dart';

@Riverpod(keepAlive: true)
Future<List<Session>> session(SessionRef ref) async =>
Future<List<Session>> session(Ref ref) async =>
ref.watch(sessionRepositoryProvider).fetchSessions();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import 'package:collection/collection.dart';
import 'package:common_data/sponsor.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'sponsor_provider.g.dart';

@Riverpod(keepAlive: true)
Future<List<SponsorWithSession>> sponsorWithSessions(
SponsorWithSessionsRef ref,
Ref ref,
) async =>
ref.watch(sponsorRepositoryProvider).fetchSponsorWithSessions();

@Riverpod(keepAlive: true)
Future<List<SponsorAndSession>> sponsorAndSessionList(
SponsorAndSessionListRef ref,
Ref ref,
) async {
final sponsorWithSessions =
await ref.watch(sponsorWithSessionsProvider.future);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ed90a76

Please sign in to comment.