Skip to content

Instantly share code, notes, and snippets.

@carzacc
Created February 2, 2020 17:42
Show Gist options
  • Save carzacc/f07e674086d9092c4e9197e03c72db7b to your computer and use it in GitHub Desktop.
Save carzacc/f07e674086d9092c4e9197e03c72db7b to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:http/http.dart' as http;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter File Upload Example',
home: StartPage(),
);
}
}
class StartPage extends StatelessWidget {
void switchScreen(str, context) =>
Navigator.push(context, MaterialPageRoute(
builder: (context) => MyHomePage(url: str)
));
@override
Widget build(context) {
TextEditingController controller = TextEditingController();
return Scaffold(
appBar: AppBar(
title: Text('Flutter File Upload Example')
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Text("Insert the URL that will receive the Multipart POST request (including the starting http://)", style: Theme.of(context).textTheme.headline),
TextField(
controller: controller,
onSubmitted: (str) => switchScreen(str, context),
),
FlatButton(
child: Text("Take me to the upload screen"),
onPressed: () => switchScreen(controller.text, context),
)
],
),
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment