Skip to content

Instantly share code, notes, and snippets.

@AdamMusa
Created August 17, 2020 16:33
Show Gist options
  • Save AdamMusa/a117d0eb0ffb4c8f3ddadeb29b00f5a2 to your computer and use it in GitHub Desktop.
Save AdamMusa/a117d0eb0ffb4c8f3ddadeb29b00f5a2 to your computer and use it in GitHub Desktop.
import 'package:flutter_app/widgets/cloudinary.dart';
import 'package:flutter_app/widgets/images_picker.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class MyHomePage extends StatefulWidget {
 @override
 _MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
 @override
 Widget build(BuildContext context) {
 final _files = Provider.of<FetchImage>(context);
 final _response = Provider.of<CloudImage>(context);
 return Scaffold(
 appBar: AppBar(
 title: const Text('Cloudinary'),
 ),
 body: _response.isloading?Center(child: Text("Click to pick images")):Padding(
 padding: const EdgeInsets.only(left: 5, right: 5, top: 12),
 child: GridView.builder(
 itemCount: 8,
 gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
 crossAxisCount: 2,
 crossAxisSpacing: 1.0,
 mainAxisSpacing: 1.0),
 itemBuilder: (BuildContext context, int index) {
 return Image.network(_response.urlList[index]);
 }
 )
 ),
 floatingActionButton: FloatingActionButton(
 child: Icon(Icons.image),
 onPressed: () async {
 await _files.init();
 await _response.upload(_files.list);
 }
 )
 );
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment