Skip to content

Commit

Permalink
Use RepositoryProvider to inject the DemoManager singleton into the w…
Browse files Browse the repository at this point in the history
…idgets
  • Loading branch information
KarinBerg committed Jan 19, 2025
1 parent 7a6840d commit 84c707d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions recipients_app/lib/my_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MultiRepositoryProvider(
providers: [
RepositoryProvider<DemoManager>(
create: (context) => demoManager,
),
RepositoryProvider(
create: (context) => MessagingRepository(
messaging: messaging,
Expand Down
3 changes: 2 additions & 1 deletion recipients_app/lib/view/pages/terms_and_conditions_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TermsAndConditionsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
final demoManager = RepositoryProvider.of<DemoManager>(context);

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -93,7 +94,7 @@ class TermsAndConditionsPage extends StatelessWidget {
context.read<AuthCubit>().updateRecipient(updated);
}
},
label: DemoManager().isDemoEnabled ? localizations.createAccountDemo : localizations.createAccount,
label: demoManager.isDemoEnabled ? localizations.createAccountDemo : localizations.createAccount,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ class _PhoneInputPageState extends State<PhoneInputPage> {
late final RoundedLoadingButtonController btnController;
late final TextEditingController phoneNumberController;
late PhoneNumber number;
late DemoManager demoManager;

@override
void initState() {
super.initState();
btnController = RoundedLoadingButtonController();
phoneNumberController = TextEditingController();
number = PhoneNumber(isoCode: "SL");
demoManager = DemoManager();
}

@override
Expand All @@ -39,7 +37,7 @@ class _PhoneInputPageState extends State<PhoneInputPage> {
@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;

final demoManager = RepositoryProvider.of<DemoManager>(context);
final isLoading = context.watch<SignupCubit>().state.status == SignupStatus.loadingPhoneNumber;

return Scaffold(
Expand Down

0 comments on commit 84c707d

Please sign in to comment.