Я пишу разветвление, что, благодаря 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
Программисты Html
1739872809
Anonymous
Я пишу разветвление, что, благодаря 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),
),
);
}
},
),
),
Подробнее здесь: [url]https://stackoverflow.com/questions/79447723/html-img-parsing-with-flutter[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия