Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c3f55dce
Commit
c3f55dce
authored
Nov 09, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #104 by adding support for HTTP post using DataPipeFiller
parent
aafce51e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
http_post.dart
examples/widgets/http_post.dart
+65
-0
mojo_client.dart
packages/flutter/lib/src/http/mojo_client.dart
+7
-2
No files found.
examples/widgets/http_post.dart
0 → 100644
View file @
c3f55dce
// Copyright 2015, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import
'package:flutter/http.dart'
as
http
;
import
'package:flutter/material.dart'
;
void
main
(
)
{
runApp
(
new
MaterialApp
(
title:
"HTTP POST Example"
,
routes:
{
'/'
:
(
RouteArguments
args
)
=>
const
PostDemo
()
}
)
);
}
class
PostDemo
extends
StatefulComponent
{
const
PostDemo
();
PostDemoState
createState
()
=>
new
PostDemoState
();
}
class
PostDemoState
extends
State
<
PostDemo
>
{
String
_response
=
null
;
void
initState
()
{
_refresh
();
super
.
initState
();
}
void
_refresh
()
{
setState
(()
{
_response
=
null
;
});
http
.
post
(
"http://httpbin.org/post"
,
body:
"asdf=42"
).
then
((
http
.
Response
response
)
{
setState
(()
{
_response
=
response
.
body
;
});
});
}
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
"HTTP POST example"
)
),
body:
new
Material
(
child:
new
Block
(
[
new
Text
(
"
${_response ?? 'Loading...'}
"
,
style:
Typography
.
black
.
body1
)]
)
),
floatingActionButton:
new
FloatingActionButton
(
child:
new
Icon
(
icon:
'navigation/refresh'
),
onPressed:
_refresh
)
);
}
}
packages/flutter/lib/src/http/mojo_client.dart
View file @
c3f55dce
...
@@ -70,8 +70,13 @@ class MojoClient {
...
@@ -70,8 +70,13 @@ class MojoClient {
mojo
.
UrlLoaderProxy
loader
=
new
mojo
.
UrlLoaderProxy
.
unbound
();
mojo
.
UrlLoaderProxy
loader
=
new
mojo
.
UrlLoaderProxy
.
unbound
();
mojo
.
UrlRequest
request
=
new
mojo
.
UrlRequest
()
mojo
.
UrlRequest
request
=
new
mojo
.
UrlRequest
()
..
url
=
url
.
toString
()
..
url
=
url
.
toString
()
..
method
=
method
..
method
=
method
;
..
body
=
body
;
if
(
body
!=
null
)
{
mojo
.
MojoDataPipe
pipe
=
new
mojo
.
MojoDataPipe
();
request
.
body
=
<
mojo
.
MojoDataPipeConsumer
>[
pipe
.
consumer
];
ByteData
data
=
new
ByteData
.
view
(
UTF8
.
encode
(
body
).
buffer
);
mojo
.
DataPipeFiller
.
fillHandle
(
pipe
.
producer
,
data
);
}
try
{
try
{
_networkService
.
ptr
.
createUrlLoader
(
loader
);
_networkService
.
ptr
.
createUrlLoader
(
loader
);
mojo
.
UrlResponse
response
=
(
await
loader
.
ptr
.
start
(
request
)).
response
;
mojo
.
UrlResponse
response
=
(
await
loader
.
ptr
.
start
(
request
)).
response
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment