Posted By

markt22 on 07/17/18


Tagged

flutter dart


Versions (?)

Flutter: Basic Stateful App


 / Published in: JavaScript
 

A very basic stateful app which displays "hello world". Useful as a blank template.

  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(new MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6. @override
  7. Widget build(BuildContext context) {
  8. return new MaterialApp(
  9. title: 'Flutter Demo',
  10. theme: new ThemeData(
  11. primarySwatch: Colors.blue,
  12. ),
  13. home: new MyHomePage(title: 'Flutter Demo Home Page'),
  14. );
  15. }
  16. }
  17.  
  18. class MyHomePage extends StatefulWidget {
  19. MyHomePage({Key key, this.title}) : super(key: key);
  20.  
  21. final String title;
  22.  
  23. @override
  24. _MyHomePageState createState() => new _MyHomePageState();
  25. }
  26.  
  27. class _MyHomePageState extends State<MyHomePage> {
  28. @override
  29. Widget build(BuildContext context) {
  30. return new Scaffold(
  31. appBar: new AppBar(
  32. title: Text(widget.title),
  33. ),
  34. body: Center(
  35. child: Text(widget.title)
  36. ),
  37. );
  38. }
  39. }

Report this snippet  

You need to login to post a comment.