mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-09-20 06:40:56 +08:00
🚧 remove new keyword to get inline with dart 2 code standard.
This commit is contained in:
@ -4,15 +4,15 @@ import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new MyGetHttpData(),
|
||||
runApp(MaterialApp(
|
||||
home: MyGetHttpData(),
|
||||
));
|
||||
}
|
||||
|
||||
// Create a stateful widget
|
||||
class MyGetHttpData extends StatefulWidget {
|
||||
@override
|
||||
MyGetHttpDataState createState() => new MyGetHttpDataState();
|
||||
MyGetHttpDataState createState() => MyGetHttpDataState();
|
||||
}
|
||||
|
||||
// Create the state for our stateful widget
|
||||
@ -44,27 +44,27 @@ class MyGetHttpDataState extends State<MyGetHttpData> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("Retrieve JSON Data via HTTP GET"),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Retrieve JSON Data via HTTP GET"),
|
||||
),
|
||||
// Create a Listview and load the data when available
|
||||
body: new ListView.builder(
|
||||
body: ListView.builder(
|
||||
itemCount: data == null ? 0 : data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return new Container(
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
// Stretch the cards in horizontal axis
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new Card(
|
||||
child: new Container(
|
||||
child: new Text(
|
||||
Card(
|
||||
child: Container(
|
||||
child: Text(
|
||||
// Read the name field value and set it in the Text widget
|
||||
data[index]['name'],
|
||||
// set some style to text
|
||||
style: new TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 20.0, color: Colors.lightBlueAccent),
|
||||
),
|
||||
// added padding
|
||||
|
Reference in New Issue
Block a user