Switch ChangeLogScreen from rootBundle to DefaultAssetBundle.of(context) so the asset source can be overridden in widget tests. Add test/widget/changelog_screen_test.dart with a happy-path test (asset loads and content is rendered) and an error-path test (missing asset shows the error message). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class ChangeLogScreen extends StatelessWidget {
|
|
const ChangeLogScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('ChangeLog')),
|
|
body: FutureBuilder<String>(
|
|
future:
|
|
DefaultAssetBundle.of(context).loadString('assets/changelog.txt'),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text('Error loading changelog: ${snapshot.error}'),
|
|
);
|
|
}
|
|
final content = snapshot.data ?? 'No changelog entries found.';
|
|
return Markdown(
|
|
data: content,
|
|
onTapLink: (text, href, title) {
|
|
if (href != null) {
|
|
unawaited(
|
|
launchUrl(
|
|
Uri.parse(href),
|
|
mode: LaunchMode.externalApplication,
|
|
),
|
|
);
|
|
}
|
|
},
|
|
styleSheet: MarkdownStyleSheet(
|
|
p: const TextStyle(fontFamily: 'monospace', fontSize: 13),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|