@@ -17,6 +17,7 @@ import 'package:qr_flutter/qr_flutter.dart';
1717import 'package:url_launcher/url_launcher.dart' ;
1818
1919import '../../app/theme.dart' ;
20+ import '../../status/status_providers.dart' ;
2021import '../../store/docs.dart' ;
2122import '../../store/store.dart' ;
2223import '../widgets/sheet_header.dart' ;
@@ -114,7 +115,7 @@ class _PublishSheetState extends ConsumerState<_PublishSheet> {
114115 Future <void > _open () async {
115116 final url = _grant? .url;
116117 if (url == null ) return ;
117- final messenger = ScaffoldMessenger . maybeOf (context) ;
118+ final status = ref.status ;
118119 final uri = Uri .tryParse (url);
119120 try {
120121 if (uri == null ) throw const FormatException ('bad url' );
@@ -123,13 +124,17 @@ class _PublishSheetState extends ConsumerState<_PublishSheet> {
123124 mode: LaunchMode .externalApplication,
124125 );
125126 if (! launched) {
126- messenger? .showSnackBar (
127- const SnackBar (content: Text ('Could not open the link' )),
127+ status.failure (
128+ 'Could not open the published link' ,
129+ source: 'docs' ,
130+ detail: url,
128131 );
129132 }
130- } catch (_) {
131- messenger? .showSnackBar (
132- const SnackBar (content: Text ('Could not open the link' )),
133+ } catch (e) {
134+ status.failure (
135+ 'Could not open the published link' ,
136+ source: 'docs' ,
137+ detail: '$url \n $e ' ,
133138 );
134139 }
135140 }
@@ -246,9 +251,10 @@ class _GrantPanel extends StatelessWidget {
246251 final VoidCallback onOpen;
247252
248253 Future <void > _copy (BuildContext context) async {
249- final messenger = ScaffoldMessenger .maybeOf (context);
254+ // A plain widget with no `ref`, hence `statusOf` (SPEC-48).
255+ final status = statusOf (context);
250256 await Clipboard .setData (ClipboardData (text: grant.url));
251- messenger ? . showSnackBar ( const SnackBar (content : Text ( 'Link copied' )) );
257+ status. success ( 'Link copied' , source : 'docs' , detail : grant.url );
252258 }
253259
254260 @override
0 commit comments