import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:anyway/modules/onboarding_card.dart'; class OnboardingAgreementCard extends StatefulWidget { final String title; final String description; final String imagePath; final String agreementTextPath; final ValueChanged onAgreementChanged; OnboardingAgreementCard({ super.key, required this.title, required this.description, required this.imagePath, required this.agreementTextPath, required this.onAgreementChanged }); @override State createState() => _OnboardingAgreementCardState(); } class _OnboardingAgreementCardState extends State { bool agreed = false; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(20), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ OnboardingCard(title: widget.title, description: widget.description, imagePath: widget.imagePath), Padding(padding: EdgeInsets.only(top: 20)), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Checkbox( value: agreed, onChanged: (value) { setState(() { agreed = value!; widget.onAgreementChanged(value); }); }, ), Text( "I agree to the ", style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: Colors.white, ), ), GestureDetector( onTap: () { // show a dialog with the agreement text showDialog( context: context, builder: (BuildContext context) { return AlertDialog( scrollable: true, content: FutureBuilder( future: DefaultAssetBundle.of(context).loadString(widget.agreementTextPath), builder: (context, snapshot) { if (snapshot.hasData) { return MarkdownBody( data: snapshot.data.toString(), ); } else { return CircularProgressIndicator(); } }, ) ); } ); }, child: Text( "Terms of Service (click to view)", style: Theme.of(context).textTheme.bodyMedium!.copyWith( color: Colors.white, fontWeight: FontWeight.bold, ), ), ), ], ), ], ), ); } }