| A web version, from the same core 23846db nandi 11h ago | 1 | /// The two things the renderer and the entry point want from the platform, |
| 2 | /// on a platform that has them. |
| 3 | /// |
| 4 | /// Both are small and neither is worth a package. What they have in common is |
| 5 | /// that a browser has neither: there is no environment to read and no file to |
| 6 | /// open, and `dart:io` cannot even be imported there — so the import lives |
| 7 | /// here, behind the conditional in `host.dart`. |
| 8 | library; |
| 9 | |
| 10 | import 'dart:io'; |
| 11 | |
| 12 | import 'package:flutter/widgets.dart'; |
| 13 | |
| 14 | /// An environment variable, or [fallback]. |
| 15 | String envOr(String name, String fallback) => |
| 16 | Platform.environment[name] ?? fallback; |
| 17 | |
| 18 | /// A picture from the filesystem — an attachment the reader picked, before it |
| 19 | /// has been uploaded anywhere. |
| 20 | ImageProvider? localImage(String path) => FileImage(File(path)); |
| 21 | |
| 22 | /// A picture from the network. |
| 23 | /// |
| 24 | /// The plain widget here. The web needs a different one, and the difference |
| 25 | /// is not cosmetic — see `host_web.dart`. |
| 26 | Widget networkImage(String url, |
| 27 | {BoxFit fit = BoxFit.contain, |
| 28 | Widget Function()? onError}) => |
| 29 | Image.network(url, |
| 30 | fit: fit, |
| 31 | errorBuilder: (_, _, _) => |
| 32 | onError == null ? const SizedBox.shrink() : onError()); |
| 33 | |
| 34 | /// The families to ask for when a widget is nothing but an emoji. |
| 35 | /// |
| 36 | /// Naming one matters here: a glyph like ✏️ is U+270F plus a variation |
| 37 | /// selector, and DejaVu Sans claims U+270F — so ordinary fallback draws the |
| 38 | /// monochrome pencil and never reaches the colour font. |
| 39 | const List<String> emojiFonts = <String>[ |
| 40 | 'Noto Color Emoji', // Linux, Android |
| 41 | 'Apple Color Emoji', // macOS, iOS |
| 42 | 'Segoe UI Emoji', // Windows |
| 43 | ]; |