mirror of
https://github.com/flutter/packages.git
synced 2025-07-02 08:34:31 +08:00
Fix null safety errors for web (#330)
This commit is contained in:
@ -13,13 +13,13 @@ import 'style_sheet.dart';
|
|||||||
import 'widget.dart';
|
import 'widget.dart';
|
||||||
|
|
||||||
typedef Widget ImageBuilder(
|
typedef Widget ImageBuilder(
|
||||||
Uri uri, String imageDirectory, double width, double height);
|
Uri uri, String? imageDirectory, double? width, double? height);
|
||||||
|
|
||||||
final ImageBuilder kDefaultImageBuilder = (
|
final ImageBuilder kDefaultImageBuilder = (
|
||||||
Uri uri,
|
Uri uri,
|
||||||
String imageDirectory,
|
String? imageDirectory,
|
||||||
double width,
|
double? width,
|
||||||
double height,
|
double? height,
|
||||||
) {
|
) {
|
||||||
if (uri.scheme == 'http' || uri.scheme == 'https') {
|
if (uri.scheme == 'http' || uri.scheme == 'https') {
|
||||||
return Image.network(uri.toString(), width: width, height: height);
|
return Image.network(uri.toString(), width: width, height: height);
|
||||||
@ -28,7 +28,9 @@ final ImageBuilder kDefaultImageBuilder = (
|
|||||||
} else if (uri.scheme == "resource") {
|
} else if (uri.scheme == "resource") {
|
||||||
return Image.asset(uri.path, width: width, height: height);
|
return Image.asset(uri.path, width: width, height: height);
|
||||||
} else {
|
} else {
|
||||||
Uri fileUri = Uri.parse(p.join(imageDirectory, uri.toString()));
|
Uri fileUri = imageDirectory != null
|
||||||
|
? Uri.parse(p.join(imageDirectory, uri.toString()))
|
||||||
|
: uri;
|
||||||
if (fileUri.scheme == 'http' || fileUri.scheme == 'https') {
|
if (fileUri.scheme == 'http' || fileUri.scheme == 'https') {
|
||||||
return Image.network(fileUri.toString(), width: width, height: height);
|
return Image.network(fileUri.toString(), width: width, height: height);
|
||||||
} else {
|
} else {
|
||||||
@ -38,10 +40,10 @@ final ImageBuilder kDefaultImageBuilder = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme)
|
final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
|
||||||
kFallbackStyle = (
|
kFallbackStyle = (
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
MarkdownStyleSheetBaseTheme baseTheme,
|
MarkdownStyleSheetBaseTheme? baseTheme,
|
||||||
) {
|
) {
|
||||||
MarkdownStyleSheet result;
|
MarkdownStyleSheet result;
|
||||||
switch (baseTheme) {
|
switch (baseTheme) {
|
||||||
@ -65,7 +67,8 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme)
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Widget _handleDataSchemeUri(Uri uri, final double width, final double height) {
|
Widget _handleDataSchemeUri(
|
||||||
|
Uri uri, final double? width, final double? height) {
|
||||||
final String mimeType = uri.data!.mimeType;
|
final String mimeType = uri.data!.mimeType;
|
||||||
if (mimeType.startsWith('image/')) {
|
if (mimeType.startsWith('image/')) {
|
||||||
return Image.memory(
|
return Image.memory(
|
||||||
|
Reference in New Issue
Block a user