pics/lib/src/app.dart
Martin Donnelly 8f3ca96bb7 init
2020-02-03 10:51:21 +00:00

39 lines
879 B
Dart

import 'package:flutter/material.dart';
import 'package:http/http.dart' show get;
class App extends StatefulWidget {
createState() {
return AppState();
}
}
// create a class that will be our custom widget
// this class must extend the 'StatelessWidget' base class
class AppState extends State<App> {
int counter = 0;
void fetchImage() async {
counter += 1;
var response = await get('https://jsonplaceholder.typicode.com/photos/$counter');
}
// must define a 'build' method that returns
// the widgets that *this* widget will show
Widget build(context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Lets see some images'),
),
body: Text('$counter'),
floatingActionButton: FloatingActionButton(
onPressed: fetchImage,
child: Icon(Icons.add),
),
));
}
}