Created
March 12, 2018 19:54
-
-
Save jonahwilliams/c60d0d9108ddcc0b775991f66428b563 to your computer and use it in GitHub Desktop.
FutureBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 The Chromium Authors. 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/material.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
runApp(new MaterialApp(home: new NewTransactionPage())); | |
} | |
class NewTransactionPage extends StatefulWidget { | |
@override | |
State createState() => new _NewTransactionPageState(); | |
} | |
class _NewTransactionPageState extends State<NewTransactionPage> { | |
@override | |
Widget build(BuildContext context) { | |
final Future<Null> futureParticipants = new Future<Null>.delayed(new Duration(seconds: 2)); | |
return new Scaffold( | |
appBar: new AppBar( | |
title: const Text('Add transaction'), | |
), | |
body: new FutureBuilder<Null>( | |
future: futureParticipants, | |
builder: (BuildContext context, AsyncSnapshot<List<Map>> snapshot) { | |
if (snapshot.connectionState != ConnectionState.done) | |
return const Text('Loading...'); | |
return | |
new DropdownButton<int>( | |
items: [1, 2, 3] | |
.map((int row) => new DropdownMenuItem<int>( | |
value: row, | |
child: const Text('lol'))) | |
.toList(), | |
onChanged: (int value) { | |
print('selected $value'); | |
}, | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment