mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Rather than managing all the Material Design icons manually, we now manage them using an icon font. The icon font contains glyphs for each icon in an efficient vector format. This patch updates the FLX tooling to include the MaterialIcons font and updates the Icon widget to use the font instead of asset images. Fixes #2313 Fixes #2218 Fixes #2009 Fixes #994
74 lines
1.6 KiB
Dart
74 lines
1.6 KiB
Dart
// 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 'dart:async';
|
|
|
|
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();
|
|
}
|
|
|
|
Future _refresh() async {
|
|
setState(() {
|
|
_response = null;
|
|
});
|
|
http.Response response = await http.post(
|
|
"http://httpbin.org/post",
|
|
body: '{"foo": "bar"}',
|
|
headers: { "Content-Type": "application/json", "baz": "qux" }
|
|
);
|
|
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(
|
|
children: <Widget>[
|
|
new Text(
|
|
"${_response ?? 'Loading...'}",
|
|
style: Typography.black.body1
|
|
)
|
|
]
|
|
)
|
|
),
|
|
floatingActionButton: new FloatingActionButton(
|
|
tooltip: 'Refresh',
|
|
child: new Icon(
|
|
icon: Icons.refresh
|
|
),
|
|
onPressed: _refresh
|
|
)
|
|
);
|
|
}
|
|
}
|