From cab829ecc2a72040004a6eb6476e8d3a6cd7bdfd Mon Sep 17 00:00:00 2001 From: vignesh Date: Wed, 22 Jun 2022 12:17:52 +0530 Subject: [PATCH] add photo design doing --- openclosenew/lib/20-ProductListing.dart | 4 +- openclosenew/lib/24_addphotos.dart | 93 +++++++++++++++---------- openclosenew/lib/25-addphotos1.dart | 1 - openclosenew/pubspec.yaml | 4 +- 4 files changed, 61 insertions(+), 41 deletions(-) diff --git a/openclosenew/lib/20-ProductListing.dart b/openclosenew/lib/20-ProductListing.dart index 0f8b10f..81dc0e9 100644 --- a/openclosenew/lib/20-ProductListing.dart +++ b/openclosenew/lib/20-ProductListing.dart @@ -486,9 +486,7 @@ void BottomSheets(BuildContext context) { height: 20, width: 20, ), - SizedBox( - width: 15, - ), + SizedBox(width: 15), Text('Non-Veg'), Spacer(), Column( diff --git a/openclosenew/lib/24_addphotos.dart b/openclosenew/lib/24_addphotos.dart index 8bea2f7..0b789c6 100644 --- a/openclosenew/lib/24_addphotos.dart +++ b/openclosenew/lib/24_addphotos.dart @@ -1,7 +1,10 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:dotted_border/dotted_border.dart'; +import 'package:flutter/services.dart'; +import 'package:image_picker/image_picker.dart'; -import '11_busiesshome.dart'; import '25-addphotos1.dart'; import 'FontFamily.dart'; import 'colors.dart'; @@ -15,6 +18,19 @@ class addphotos extends StatefulWidget { } class _addphtosState extends State { + File? image; + Future pickImage() async { + try { + final image = await ImagePicker().pickImage(source: ImageSource.gallery); + if (image == null) return; + final imageTemporary = File(image.path); + + setState(() => this.image = imageTemporary); + } on PlatformException catch (e) { + print('failed to pick image:$e'); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -63,42 +79,47 @@ class _addphtosState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ InkWell( - onTap: () { - Navigator.pop(context); - }, - child: DottedBorder( - dashPattern: [5, 5, 5, 5], - color: primaryColor, - padding: EdgeInsets.all(5), - radius: Radius.circular(6), - child: Container( - height: 100, - width: 330, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image( - image: - AssetImage('assets/images/gallery-icon.png'), - color: primaryColor, - width: 30, - height: 30, - ), - SizedBox(width: 10), - Text( - 'Upload Photos', - style: TextStyle( - fontFamily: Font, - fontStyle: FontStyle.normal, - fontWeight: FontWeight.w400, - fontSize: HeadText, - color: primaryColor, + onTap: () => pickImage(), + child: image != null + ? Image.file( + image!, + width: 330, + height: 100, + fit: BoxFit.cover, + ) + : DottedBorder( + dashPattern: [5, 5, 5, 5], + color: primaryColor, + padding: EdgeInsets.all(5), + radius: Radius.circular(6), + child: Container( + height: 100, + width: 330, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage( + 'assets/images/gallery-icon.png'), + color: primaryColor, + width: 30, + height: 30, + ), + SizedBox(width: 10), + Text( + 'Upload Photos', + style: TextStyle( + fontFamily: Font, + fontStyle: FontStyle.normal, + fontWeight: FontWeight.w400, + fontSize: HeadText, + color: primaryColor, + ), + ) + ], ), - ) - ], - ), - ), - ), + ), + ), ), ], ), diff --git a/openclosenew/lib/25-addphotos1.dart b/openclosenew/lib/25-addphotos1.dart index 30ce72a..e7b24e6 100644 --- a/openclosenew/lib/25-addphotos1.dart +++ b/openclosenew/lib/25-addphotos1.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; import 'FontFamily.dart'; import 'colors.dart'; import 'fontsize.dart'; diff --git a/openclosenew/pubspec.yaml b/openclosenew/pubspec.yaml index a9ffd34..d2687a8 100644 --- a/openclosenew/pubspec.yaml +++ b/openclosenew/pubspec.yaml @@ -32,7 +32,6 @@ dependencies: snippet_coder_utils: ^1.0.8 dotted_border: ^2.0.0+2 flutter_switch: ^0.3.2 - image_picker: ^0.8.5+3 # The following adds the Cupertino Icons fonts to your application. @@ -42,6 +41,9 @@ dependencies: intl_phone_number_input: ^0.7.0+2 get: ^4.5.1 smooth_page_indicator: ^1.0.0+2 + image_picker: ^0.8.5+3 + +