LCOV - code coverage report
Current view: top level - lib/design/wrapper - markdown_builder_wrapper.dart Coverage Total Hit
Test: lcov.info Lines: 81.2 % 16 13
Test Date: 2026-11-14 15:08:11 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:material_ui/material_ui.dart';
       7              : import 'package:flutter_markdown_plus/flutter_markdown_plus.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            1 :   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            1 :   @override
      28              :   Widget build(BuildContext context) {
      29            1 :     return FutureBuilder(
      30            3 :       future: DefaultAssetBundle.of(context).loadString(url),
      31            1 :       builder: builder ??
      32            1 :           (BuildContext context, AsyncSnapshot<String> snapshot) {
      33            1 :             if (snapshot.hasData) {
      34            1 :               return Directionality(
      35            1 :                 textDirection: AppDesign.getAlignment<TextDirection>(),
      36            1 :                 child: Markdown(
      37            2 :                     data: (snapshot.data ?? '').replaceAll('../images', 'resource:assets/images'),
      38            2 :                     onTapLink: onTapLink ?? _openURL),
      39              :               );
      40              :             }
      41            1 :             return Container();
      42              :           },
      43              :     );
      44              :   }
      45              : }
        

Generated by: LCOV version 2.0-1