mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
monkey.svg download to user device
This commit is contained in:
parent
b2ec2763fb
commit
c6c2b42923
1 changed files with 35 additions and 3 deletions
|
@ -50,11 +50,35 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
||||||
|
|
||||||
final http.Response response = await http
|
final http.Response response = await http
|
||||||
.get(Uri.parse('https://monkey.banano.cc/api/v1/monkey/$address'));
|
.get(Uri.parse('https://monkey.banano.cc/api/v1/monkey/$address'));
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final decodedResponse = response.bodyBytes;
|
final decodedResponse = response.bodyBytes;
|
||||||
final directory = await getApplicationDocumentsDirectory();
|
Directory directory = await getApplicationDocumentsDirectory();
|
||||||
// Directory appDir = await getTemporaryDirectory();
|
late Directory sampleFolder;
|
||||||
final docPath = directory.path;
|
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
directory = Directory("/storage/emulated/0/");
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
sampleFolder = Directory(directory!.path);
|
||||||
|
} else if (Platform.isLinux) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isWindows) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isMacOS) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!sampleFolder.existsSync()) {
|
||||||
|
sampleFolder.createSync(recursive: true);
|
||||||
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
// todo: come back to this
|
||||||
|
debugPrint("$e $s");
|
||||||
|
}
|
||||||
|
|
||||||
|
final docPath = sampleFolder.path;
|
||||||
final filePath = "$docPath/monkey.svg";
|
final filePath = "$docPath/monkey.svg";
|
||||||
|
|
||||||
File imgFile = File(filePath);
|
File imgFile = File(filePath);
|
||||||
|
@ -86,6 +110,14 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
directory = Directory("/storage/emulated/0/");
|
directory = Directory("/storage/emulated/0/");
|
||||||
sampleFolder = Directory('${directory!.path}Documents');
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
sampleFolder = Directory(directory!.path);
|
||||||
|
} else if (Platform.isLinux) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isWindows) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
|
} else if (Platform.isMacOS) {
|
||||||
|
sampleFolder = Directory('${directory!.path}Documents');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue