Skip to content

Commit

Permalink
Fix spherical image loading and permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tcgj committed Jan 9, 2021
1 parent 066f694 commit 15cd738
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
android:name="flutterEmbedding"
android:value="2" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
17 changes: 8 additions & 9 deletions lib/helpers/sphere.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
import 'dart:math' as math;
Expand Down Expand Up @@ -112,16 +113,14 @@ class _SphereState extends State<Sphere> with TickerProviderStateMixin {
}

void loadSurface() {
rootBundle.load(widget.surface).then((data) {
ui.decodeImageFromList(data.buffer.asUint8List(), (image) {
image.toByteData(format: ui.ImageByteFormat.rawRgba).then((pixels) {
surface = pixels.buffer.asUint32List();
surfaceWidth = image.width.toDouble();
surfaceHeight = image.height.toDouble();
setState(() {});
});
File(widget.surface).readAsBytes().then((bytes) => ui.decodeImageFromList(bytes, (image) {
image.toByteData(format: ui.ImageByteFormat.rawRgba).then((pixels) {
surface = pixels.buffer.asUint32List();
surfaceWidth = image.width.toDouble();
surfaceHeight = image.height.toDouble();
setState(() {});
});
});
}));
}

@override
Expand Down
8 changes: 2 additions & 6 deletions lib/profdex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class _ProfDexState extends State<ProfDex> {
profPaths = List(profNames.length);
for (var i = 0; i < profNames.length; i++) {
String escName = profNames[i].replaceAll(RegExp(' +'), '_');
String imgPath = getImageDir(escName);
setState(() {
profPaths[i] = imgPath;
profPaths[i] = getImageDir(escName);
});
}

Expand Down Expand Up @@ -203,10 +202,7 @@ class _ProfDexState extends State<ProfDex> {
builder: (context) => Award(
url: profPaths[index] +
'/' +
rng
.nextInt(profCollections[
index])
.toString() +
rng.nextInt(profCollections[index]).toString() +
'.jpg')));
},
child: ImageRotator(profPaths[index],
Expand Down

0 comments on commit 15cd738

Please sign in to comment.