import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:async'; import 'package:rxdart/rxdart.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:flutter/services.dart'; void main() => runApp(MaterialApp(home: MyApp(),)); /* 1. Copy aria2c executable to ``/mnt/sdcard`` on your device. 2. Run Android Terminal Emulator. 3. ``mkdir /data/data/jackpal.androidterm/aria2`` 4. ``cat /mnt/sdcard/aria2c > /data/data/jackpal.androidterm/aria2/aria2c`` 5. ``chmod 744 /data/data/jackpal.androidterm/aria2/aria2c`` 6. Add the following commands to the initial command of Android Terminal Emulator:: export HOME=/data/data/jackpal.androidterm/aria2; cd $HOME 7. Exit Android Terminal Emulator. 8. Run Android Terminal Emulator again. 9. See whether aria2c actually works by invoking ``./aria2c -v`` */ class MyApp extends StatelessWidget { DataBloc bloc; checkPermission()async{ var per = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); if(per!=PermissionStatus.granted){ await PermissionHandler().requestPermissions([PermissionGroup.storage]); } } cp()async{ await checkPermission(); Directory tempDir = await getExternalStorageDirectory(); String workDir = join(tempDir.path, ''); var appLocation = await getApplicationDocumentsDirectory(); await Process.run('chmod', ['755', appLocation.path+'/aria2']).then((e){ print(e.toString()); print(e.stdout); print(e.stderr); print(e.exitCode); print('==============='); }); // var file1 = await rootBundle.load('assets/aria2c'); // var buf = file1.buffer; // File(join(appLocation.path, 'aria2')).writeAsBytesSync(buf.asUint8List()); await Process.run('${appLocation.path}'+'/aria2', ['-v']).then((e){ print(e.stdout); print(e.stderr); print(e.exitCode); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('sss'),), body: Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ RaisedButton(child: Text('mkdir'),onPressed: (){ cp(); },), RaisedButton(child: Text('delete'),onPressed: (){ },), Container( width: 50,height: 50,child: Image(image: AssetImage('assets/img/a.png',),fit: BoxFit.cover,)), ], ), ), ); } } class DataBloc { ReplaySubject dataBloc = ReplaySubject(); }