Я пишу разветвление, что, благодаря WP-JSON, извлекает статью с веб-сайта WP. Если в статье есть изображение, оно хорошо отображается, полная ширина и не растянута. Я бы хотел, чтобы IMG ведет себя как показанное изображение. " /> < /p>
< / p>
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
.....
if(article.featuredImageUrl.isNotEmpty && !_isOffline)
CachedNetworkImage(
imageUrl: article.featuredImageUrl,
fit: BoxFit.fitWidth,
width: double.infinity,
cacheManager: customCacheManager,
placeholder: (context, url) => Shimmer.fromColors(
baseColor:
isDarkMode ? Colors.grey[800] ! : Colors.grey[300] !,
highlightColor:
isDarkMode ? Colors.grey[700] ! : Colors.grey[100] !,
child: Container(
width: double.infinity,
height: 200, // Altezza di default per il placeholder
color: Colors.white,
),
),
errorWidget: (context, error, stackTrace) {
return Container(
width: double.infinity,
height: 200,
color: Colors.grey[300],
child: const Center(
child: Icon(Icons.error_outline),
),
);
},
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Html(
data: article.content,
style: {
"body": Style(
fontSize: FontSize(16 * textScale),
lineHeight: LineHeight(1.6),
margin: Margins.zero,
color: isDarkMode ?
const Color(0xFFFFFFFF): Colors.black87,
),
"p": Style(
margin: Margins.only(bottom: 16),
fontSize: FontSize(16 * textScale),
color: isDarkMode ?
const Color(0xFFFFFFFF): Colors.black87,
),
"h1, h2, h3, h4, h5, h6": Style(
fontSize: FontSize.larger,
margin: Margins.only(bottom: 16, top: 24),
color:
isDarkMode ?
const Color(0xFFFFFFFF): Colors.black,
),
"strong": Style(
fontWeight: FontWeight.bold,
),
"em": Style(
fontStyle: FontStyle.italic,
),
"img": Style(
alignment: Alignment.center,
margin: Margins.symmetric(vertical: 16),
display: Display.block,
),
"figure": Style(
alignment: Alignment.center,
margin: Margins.symmetric(vertical: 16),
padding: HtmlPaddings.zero,
),
"figure img": Style(
alignment: Alignment.center,
margin: Margins.zero,
),
"figcaption": Style(
textAlign: TextAlign.center,
fontSize: FontSize(14 * textScale),
color: isDarkMode ? Colors.grey[400] : Colors.grey[600],
margin: Margins.only(top: 8),
),
},
shrinkWrap: true,
onLinkTap: (url, attributes, element) {
if (url != null && !_isOffline) {
_launchUrl(url);
} else if (_isOffline) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content:
Text('I link non sono disponibili offline'),
duration: Duration(seconds: 2),
),
);
}
},
),
),
Подробнее здесь: https://stackoverflow.com/questions/794 ... th-flutter
HTML IMG SAINGING с трепетом ⇐ Html
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Flutter: Я хочу показать раскрывающееся список под раскрывающимся трепетом
Anonymous » » в форуме Android - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Где я могу просматривать выходной фазы xcode runscript при создании для iOS с трепетом?
Anonymous » » в форуме IOS - 0 Ответы
- 31 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Я испортил свою сборку XCode с трепетом. Кто -нибудь знает, как исправить?
Anonymous » » в форуме IOS - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-