Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Sep 18, 2019
1 parent 28cedf0 commit 5a3148a
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 63 deletions.
93 changes: 88 additions & 5 deletions .gitignore
@@ -1,11 +1,94 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.idea
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.vscode/

# Flutter repo-specific
/bin/cache/
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/docs/doc/
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/packages/flutter/coverage/
version

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/
ios/.generated/
packages
.flutter-plugins
pubspec.lock
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# Firebase configuration files
ios/Runner/GoogleService-Info.plist
android/app/google-services.json
11 changes: 11 additions & 0 deletions ios/Flutter/flutter_export_environment.sh
@@ -0,0 +1,11 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/andrea/Documents/flutter_stable"
export "FLUTTER_APPLICATION_PATH=/Users/andrea/dev/WORK/MuseVisions/flutter/image_picker_demo_flutter"
export "FLUTTER_TARGET=/Users/andrea/dev/WORK/MuseVisions/flutter/image_picker_demo_flutter/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/andrea/Documents/flutter_stable/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=0.0.1"
export "FLUTTER_BUILD_NUMBER=0.0.1"
export "TRACK_WIDGET_CREATION=true"
9 changes: 5 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -41,7 +40,6 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
651DF6C020887679006B097F /* FlutterChannelManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlutterChannelManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,7 +72,6 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
Expand Down Expand Up @@ -160,6 +157,7 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = M54ZVB688G;
LastSwiftMigration = 0910;
};
};
Expand Down Expand Up @@ -192,7 +190,6 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -374,12 +371,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = M54ZVB688G;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -403,12 +402,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = M54ZVB688G;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down
25 changes: 12 additions & 13 deletions lib/image_picker_channel.dart
Expand Up @@ -4,35 +4,34 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

enum ImageSource {
photos,
camera
}
enum ImageSource { photos, camera }

String _stringImageSource(ImageSource imageSource) {
switch (imageSource) {
case ImageSource.photos: return 'photos';
case ImageSource.camera: return 'camera';
case ImageSource.photos:
return 'photos';
case ImageSource.camera:
return 'camera';
}
return null;
}

abstract class ImagePicker {
Future<File> pickImage({ImageSource imageSource});
}

class ImagePickerChannel implements ImagePicker {

static const platform = const MethodChannel('com.musevisions.flutter/imagePicker');
static const platform =
const MethodChannel('com.musevisions.flutter/imagePicker');

Future<File> pickImage({ImageSource imageSource}) async {

var stringImageSource = _stringImageSource(imageSource);
var result = await platform.invokeMethod('pickImage', stringImageSource);
final stringImageSource = _stringImageSource(imageSource);
final result = await platform.invokeMethod('pickImage', stringImageSource);
if (result is String) {
return new File(result);
return File(result);
} else if (result is FlutterError) {
throw result;
}
return null;
}
}
}
80 changes: 40 additions & 40 deletions lib/main.dart
Expand Up @@ -3,18 +3,17 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'image_picker_channel.dart';

void main() => runApp(new MyApp());
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Image Picker Demo'),
home: MyHomePage(title: 'Image Picker Demo'),
);
}
}
Expand All @@ -25,76 +24,77 @@ class MyHomePage extends StatefulWidget {
final String title;

@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}


class _MyHomePageState extends State<MyHomePage> {

ImagePicker _imagePicker = new ImagePickerChannel();
final ImagePicker _imagePicker = ImagePickerChannel();

File _imageFile;

void captureImage(ImageSource captureMode) async {
Future<void> captureImage(ImageSource imageSource) async {
try {
var imageFile = await _imagePicker.pickImage(captureMode: captureMode);
final imageFile = await _imagePicker.pickImage(imageSource: imageSource);
setState(() {
_imageFile = imageFile;
});
}
catch (e) {
} catch (e) {
print(e);
}
}

Widget _buildImage() {
if (_imageFile != null) {
return new Image.file(_imageFile);
return Image.file(_imageFile);
} else {
return new Text('Take an image to start', style: new TextStyle(fontSize: 18.0));
return Text('Take an image to start', style: TextStyle(fontSize: 18.0));
}
}

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: new Column(
body: Column(
children: [
new Expanded(child: new Center(child: _buildImage())),
_buildButtons()
]
Expanded(child: Center(child: _buildImage())),
_buildButtons(),
],
),
);
}


Widget _buildButtons() {
return new ConstrainedBox(
constraints: BoxConstraints.expand(height: 80.0),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
_buildActionButton(new Key('retake'), 'Photos', () => captureImage(ImageSource.photos)),
_buildActionButton(new Key('upload'), 'Camera', () => captureImage(ImageSource.camera)),
]
));
return ConstrainedBox(
constraints: BoxConstraints.expand(height: 80.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
_buildActionButton(
key: Key('retake'),
text: 'Photos',
onPressed: () => captureImage(ImageSource.photos),
),
_buildActionButton(
key: Key('upload'),
text: 'Camera',
onPressed: () => captureImage(ImageSource.camera),
),
]));
}

Widget _buildActionButton(Key key, String text, Function onPressed) {
return new Expanded(
child: new FlatButton(
Widget _buildActionButton({Key key, String text, Function onPressed}) {
return Expanded(
child: FlatButton(
key: key,
child: new Text(text, style: new TextStyle(fontSize: 20.0)),
shape: new RoundedRectangleBorder(),
child: Text(text, style: TextStyle(fontSize: 20.0)),
shape: RoundedRectangleBorder(),
color: Colors.blueAccent,
textColor: Colors.white,
onPressed: onPressed),
);
}
}


7 changes: 6 additions & 1 deletion pubspec.yaml
@@ -1,13 +1,18 @@
name: image_picker_demo_flutter
description: A new Flutter project.

version: 0.0.1

environment:
sdk: ">=2.2.2 <3.0.0"

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
cupertino_icons: ^0.1.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 5a3148a

Please sign in to comment.