image_grid 0.0.1 copy "image_grid: ^0.0.1" to clipboard
image_grid: ^0.0.1 copied to clipboard

outdated

This is project show image grid and with add button to add more images and minus to remove image in grid

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:image_grid/grid_image.dart';
import 'package:image_grid/image_grid.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await ImageGrid.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home:Home() ,
    );
  }
}

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

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

class _HomeState extends State<Home> {
  int imagecount = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          GridImage(
            compressImage: true,
            context: context,
            onchange: (List<File> files) {
              setState(() {
                imagecount = files.length;
              });
            },
            title: "Select Image",
          ),
          SizedBox(
            height: 10,
          ),
          Text("Total images are added ${imagecount}")
        ],
      ),
    );
  }
}
2
likes
0
pub points
50%
popularity

Publisher

unverified uploader

This is project show image grid and with add button to add more images and minus to remove image in grid

License

unknown (license)

Dependencies

file_support, flutter, flutter_web_plugins, image_picker, logger, material_dialogs

More

Packages that depend on image_grid