import io,,,,,,,
from https://pub.dev/packages/large_file_copy
Directory directory = await getApplicationDocumentsDirectory();
var dbPath = join(directory.path, "app.db");
if (FileSystemEntity.typeSync(dbPath) == FileSystemEntityType.notFound) {
ByteData data = await rootBundle.load("assets/my_db_file.db");
List<int> bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await File(dbPath).writeAsBytes(bytes);
}
var file1 = File(join(tempDir.path, '0/2048.apk'));
var newFile = await file1.copy(join(tempDir.path, '4/1.apk'));
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, '4'); // var p = await Process.run('mkdir', [workDir]).then((ProcessResult e){ // print(e.stderr); // print(e.exitCode); // }); var file1 = await rootBundle.load('assets/aria2c'); var buf = file1.buffer; File(join(workDir, 'xxx')).writeAsBytesSync(buf.asUint8List()); // var newFile = await file1.copy(join(tempDir.path, '4/1.apk')); print('done'); } @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( 50,height: 50,child: Image(image: AssetImage('assets/img/a.png',),fit: BoxFit.cover,)), // Container( // 50, height: 50,child: Text(' '),decoration: BoxDecoration( // image: DecorationImage(image: AssetImage('assets/img/a.png')), // ),), ], ), ), ); } } class DataBloc { ReplaySubject dataBloc = ReplaySubject(); } //void shell(String cmd, List<String> opts, void onExit(int exitCode))async{ // var p = await Process.start(cmd, opts); // p.stdout.pipe(stdout); // stdin.pipe(p.stdin); // p.onExit = (exitCode)async{ // await p.kill(); // onExit(exitCode); // } //} //void shell(String cmd, List<String> opts, void onExit(int exitCode)) { // var p = Process.start(cmd, opts); // p.stdout.pipe(stdout); // Process output to stdout. // stdin.pipe(p.stdin); // stdin to process input. // p.onExit = (exitCode) { // p.close(); // onExit(exitCode); // }; //}