mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-06 18:25:11 +08:00
chore: Migration to Dart 3.8 (#6668)
* Migration to Dart 3.8 * New GA * Fix dartdoc
This commit is contained in:
@ -5,9 +5,7 @@ import 'package:smooth_app/generic_lib/html/smooth_html_marker_chip.dart';
|
||||
import 'package:smooth_app/generic_lib/html/smooth_html_marker_decimal.dart';
|
||||
|
||||
class SmoothHtmlWidgetFactory extends WidgetFactory {
|
||||
SmoothHtmlWidgetFactory({
|
||||
required this.onLinkClicked,
|
||||
});
|
||||
SmoothHtmlWidgetFactory({required this.onLinkClicked});
|
||||
|
||||
final Function(String link) onLinkClicked;
|
||||
|
||||
@ -27,9 +25,7 @@ class SmoothHtmlWidgetFactory extends WidgetFactory {
|
||||
child: SelectableText.rich(
|
||||
TextSpan(
|
||||
children: <InlineSpan>[text],
|
||||
style: resolved.prepareTextStyle().copyWith(
|
||||
height: 1.6,
|
||||
),
|
||||
style: resolved.prepareTextStyle().copyWith(height: 1.6),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -6,17 +6,14 @@ import 'package:smooth_app/themes/smooth_theme.dart';
|
||||
import 'package:smooth_app/themes/smooth_theme_colors.dart';
|
||||
|
||||
class SmoothHtmlFakeButton extends StatelessWidget {
|
||||
const SmoothHtmlFakeButton({
|
||||
required this.children,
|
||||
super.key,
|
||||
});
|
||||
const SmoothHtmlFakeButton({required this.children, super.key});
|
||||
|
||||
final List<InlineSpan> children;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final SmoothColorsThemeExtension extension =
|
||||
context.extension<SmoothColorsThemeExtension>();
|
||||
final SmoothColorsThemeExtension extension = context
|
||||
.extension<SmoothColorsThemeExtension>();
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
@ -57,10 +54,7 @@ class SmoothHtmlFakeButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const icons.ExternalLink(
|
||||
color: Colors.black,
|
||||
size: 16.0,
|
||||
)
|
||||
const icons.ExternalLink(color: Colors.black, size: 16.0),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -9,14 +9,15 @@ class SmoothHtmlChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final SmoothColorsThemeExtension extension =
|
||||
context.extension<SmoothColorsThemeExtension>();
|
||||
final SmoothColorsThemeExtension extension = context
|
||||
.extension<SmoothColorsThemeExtension>();
|
||||
|
||||
/// We can't use top Padding, so we draw on a canvas
|
||||
return CustomPaint(
|
||||
painter: _HtmlChipPainter(
|
||||
color:
|
||||
context.lightTheme() ? extension.greyMedium : extension.greyNormal,
|
||||
color: context.lightTheme()
|
||||
? extension.greyMedium
|
||||
: extension.greyNormal,
|
||||
textDirection: Directionality.of(context),
|
||||
),
|
||||
child: const SizedBox.square(dimension: 10.0),
|
||||
@ -25,10 +26,7 @@ class SmoothHtmlChip extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _HtmlChipPainter extends CustomPainter {
|
||||
_HtmlChipPainter({
|
||||
required this.color,
|
||||
required this.textDirection,
|
||||
});
|
||||
_HtmlChipPainter({required this.color, required this.textDirection});
|
||||
|
||||
final Color color;
|
||||
final TextDirection textDirection;
|
||||
@ -55,10 +53,7 @@ class _HtmlChipPainter extends CustomPainter {
|
||||
textPainter.layout();
|
||||
textPainter.paint(
|
||||
canvas,
|
||||
Offset(
|
||||
(size.width - dimension) / 2,
|
||||
(size.height - dimension) / 2,
|
||||
),
|
||||
Offset((size.width - dimension) / 2, (size.height - dimension) / 2),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,22 +4,20 @@ import 'package:smooth_app/themes/smooth_theme_colors.dart';
|
||||
import 'package:smooth_app/themes/theme_provider.dart';
|
||||
|
||||
class SmoothHtmlDecimal extends StatelessWidget {
|
||||
const SmoothHtmlDecimal({
|
||||
required this.index,
|
||||
super.key,
|
||||
});
|
||||
const SmoothHtmlDecimal({required this.index, super.key});
|
||||
|
||||
final int index;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final SmoothColorsThemeExtension extension =
|
||||
context.extension<SmoothColorsThemeExtension>();
|
||||
final SmoothColorsThemeExtension extension = context
|
||||
.extension<SmoothColorsThemeExtension>();
|
||||
|
||||
return CustomPaint(
|
||||
painter: _HtmlDecimalPainter(
|
||||
color:
|
||||
context.lightTheme() ? extension.greyMedium : extension.greyNormal,
|
||||
color: context.lightTheme()
|
||||
? extension.greyMedium
|
||||
: extension.greyNormal,
|
||||
index: index,
|
||||
textDirection: Directionality.of(context),
|
||||
textStyle: const TextStyle(
|
||||
@ -59,10 +57,7 @@ class _HtmlDecimalPainter extends CustomPainter {
|
||||
);
|
||||
|
||||
final TextPainter textPainter = TextPainter(textDirection: textDirection);
|
||||
textPainter.text = TextSpan(
|
||||
text: index.toString(),
|
||||
style: textStyle,
|
||||
);
|
||||
textPainter.text = TextSpan(text: index.toString(), style: textStyle);
|
||||
textPainter.layout();
|
||||
textPainter.paint(
|
||||
canvas,
|
||||
|
@ -23,22 +23,19 @@ class SmoothHtmlWidget extends StatelessWidget {
|
||||
textStyle: textStyle,
|
||||
customStylesBuilder: (dom.Element element) =>
|
||||
element.classes.contains('unknown_ingredient')
|
||||
? <String, String>{
|
||||
'font-weight': 'bold',
|
||||
}
|
||||
: null,
|
||||
? <String, String>{'font-weight': 'bold'}
|
||||
: null,
|
||||
onTapUrl: (String url) async {
|
||||
try {
|
||||
await LaunchUrlHelper.launchURL(url);
|
||||
} catch (_) {
|
||||
if (context.mounted) {
|
||||
final AppLocalizations appLocalizations =
|
||||
AppLocalizations.of(context);
|
||||
final AppLocalizations appLocalizations = AppLocalizations.of(
|
||||
context,
|
||||
);
|
||||
|
||||
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(appLocalizations.link_cant_be_opened),
|
||||
),
|
||||
SnackBar(content: Text(appLocalizations.link_cant_be_opened)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user