cross_file_image 1.1.0 copy "cross_file_image: ^1.1.0" to clipboard
cross_file_image: ^1.1.0 copied to clipboard

ImageProvider for XFile.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:cross_file_image/cross_file_image.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  HomePageState createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
  XFile? file;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: file == null
            ? const Text('Click floating button to pick some image')
            : Image(image: XFileImage(file!)),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          final file =
              await ImagePicker().pickImage(source: ImageSource.gallery);
          setState(() => this.file = file);
        },
        tooltip: 'Pick Image',
        child: const Icon(Icons.add),
      ),
    );
  }
}
10
likes
150
points
4.36k
downloads

Publisher

unverified uploader

Weekly Downloads

ImageProvider for XFile.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cross_file, flutter

More

Packages that depend on cross_file_image