Skip to content

Commit

Permalink
Change variable name + add image
Browse files Browse the repository at this point in the history
  • Loading branch information
anlam87 committed Oct 23, 2019
1 parent 3bcc74b commit 354bce9
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 11 deletions.
Binary file added example/assets/image1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,34 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String md5SumPlugin;
String md5SumDart;
String md5SumDartCrypto;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
//Create image
//Prepare image
var directory = await getApplicationDocumentsDirectory();
var dbPath = join(directory.path, 'image.jpg');
var data = await rootBundle.load('assets/image.jpg');
var dbPath = join(directory.path, 'image1.jpg');
var data = await rootBundle.load('assets/image1.jpg');
List<int> bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await File(dbPath).writeAsBytes(bytes);
print('path: $dbPath');

//Get md5 sum from Crypto
var date = DateTime.now();
md5SumDart = await calculateMD5SumAsyncWithCrypto(dbPath);
md5SumDart +=
md5SumDartCrypto = await calculateMD5SumAsyncWithCrypto(dbPath);
print('md5SumDartCrypto: $md5SumDartCrypto');
md5SumDartCrypto +=
' - duration: ${DateTime.now().difference(date).inMilliseconds}';

//Get md5 sum from Plugin
date = DateTime.now();
md5SumPlugin = await calculateMD5SumAsyncWithPlugin(dbPath);
print('md5SumPlugin: $md5SumPlugin');
md5SumPlugin +=
' - duration: ${DateTime.now().difference(date).inMilliseconds}';
} on PlatformException {
md5SumPlugin = 'Failed to get md5 from Crypto';
md5SumDart = 'Failed to get md5 from Plugin';
md5SumPlugin = 'Failed to get md5 from Plugin';
md5SumDartCrypto = 'Failed to get md5 from Crypto';
}

// If the widget was removed from the tree while the asynchronous platform
Expand All @@ -65,7 +67,7 @@ class _MyAppState extends State<MyApp> {

setState(() {
_md5SumPlugin = md5SumPlugin;
_md5SumDart = md5SumDart;
_md5SumDart = md5SumDartCrypto;
});
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "1.0.2"
meta:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ flutter:

# To add assets to your application, add an assets section, like this:
assets:
- assets/image.jpg
- assets/
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
Expand Down
1 change: 1 addition & 0 deletions md5_plugin.iml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/md5_plugin/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/md5_plugin/example/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/md5_plugin/example/ios/Flutter/App.framework/flutter_assets/packages" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/App.framework/flutter_assets/packages" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
Expand Down
96 changes: 96 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
Expand All @@ -13,18 +34,93 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
typed_data:
dependency: transitive
description:
Expand Down

0 comments on commit 354bce9

Please sign in to comment.