outsourced httpRequest method
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'package:fforte/other/methods.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'addCam/add_cam_main.dart';
|
||||
@@ -8,6 +11,18 @@ import 'addCam/add_cam_main.dart';
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
void _sendFile() async {
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles();
|
||||
|
||||
if (result != null) {
|
||||
File file = File(result.files.single.path!);
|
||||
String content = await file.readAsString();
|
||||
|
||||
Methods(content).httpRequest();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
@@ -47,7 +62,9 @@ class HomePage extends StatelessWidget {
|
||||
child: Text(AppLocalizations.of(context)!.addplace)),
|
||||
ElevatedButton(onPressed: () => Navigator.pushNamed(context, '/viewCams'),
|
||||
child: Text(AppLocalizations.of(context)!.viewplaces)),
|
||||
ElevatedButton(onPressed: () {}, child: Text(AppLocalizations.of(context)!.sendfile))
|
||||
ElevatedButton(onPressed: () {
|
||||
_sendFile();
|
||||
}, child: Text(AppLocalizations.of(context)!.sendfile))
|
||||
],
|
||||
)),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user