LCOV - code coverage report
Current view: top level - lib/design/wrapper - markdown_builder_wrapper.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 16 0.0 %
Date: 2024-10-04 11:09:33 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2024 The terCAD team. All rights reserved.
       2             : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3             : 
       4             : import 'package:app_finance/_classes/herald/app_design.dart';
       5             : import 'package:app_finance/_mixins/launcher_mixin.dart';
       6             : import 'package:flutter/material.dart';
       7             : import 'package:flutter_markdown/flutter_markdown.dart';
       8             : 
       9             : class MarkdownBuilderWrapper extends StatelessWidget with LauncherMixin {
      10             :   final String url;
      11             :   final Widget Function(BuildContext, AsyncSnapshot<String>)? builder;
      12             :   final Function(String, String?, String)? onTapLink;
      13             : 
      14           0 :   const MarkdownBuilderWrapper({
      15             :     super.key,
      16             :     required this.url,
      17             :     this.builder,
      18             :     this.onTapLink,
      19             :   });
      20             : 
      21           0 :   _openURL(_, url, __) {
      22           0 :     if (url != null && (url.contains('https://') || url.contains('mailto:'))) {
      23           0 :       openURL(url);
      24             :     }
      25             :   }
      26             : 
      27           0 :   @override
      28             :   Widget build(BuildContext context) {
      29           0 :     return FutureBuilder(
      30           0 :       future: DefaultAssetBundle.of(context).loadString(url),
      31           0 :       builder: builder ??
      32           0 :           (BuildContext context, AsyncSnapshot<String> snapshot) {
      33           0 :             if (snapshot.hasData) {
      34           0 :               return Directionality(
      35           0 :                 textDirection: AppDesign.getAlignment<TextDirection>(),
      36           0 :                 child: Markdown(
      37           0 :                     data: (snapshot.data ?? '').replaceAll('../images', 'resource:assets/images'),
      38           0 :                     onTapLink: onTapLink ?? _openURL),
      39             :               );
      40             :             }
      41           0 :             return Container();
      42             :           },
      43             :     );
      44             :   }
      45             : }

Generated by: LCOV version 1.14