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),
      ),
    );
  }
}
9
likes
130
pub points
92%
popularity

Publisher

unverified uploader

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