mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Adds ai_recipe_generation sample (#2242)
Adding the demo app from my I/O talk. Because AI. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. --------- Co-authored-by: Brett Morgan <brett.morgan@gmail.com>
This commit is contained in:
41
ai_recipe_generation/lib/widgets/cross_image_widget.dart
Normal file
41
ai_recipe_generation/lib/widgets/cross_image_widget.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class CrossImage extends StatelessWidget {
|
||||
const CrossImage({
|
||||
super.key,
|
||||
required this.file,
|
||||
this.fit = BoxFit.cover,
|
||||
this.height = 100,
|
||||
this.width = 100,
|
||||
});
|
||||
|
||||
final XFile file;
|
||||
final BoxFit fit;
|
||||
final double width;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (kIsWeb) {
|
||||
return Image.network(
|
||||
file.path,
|
||||
fit: fit,
|
||||
);
|
||||
} else {
|
||||
return Image.file(
|
||||
File(file.path),
|
||||
height: height,
|
||||
width: width,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static DecorationImage decoration(XFile file, {BoxFit fit = BoxFit.cover}) {
|
||||
final image = kIsWeb ? NetworkImage(file.path) : FileImage(File(file.path));
|
||||
return DecorationImage(image: image as ImageProvider, fit: fit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user