fork download
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4. runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatelessWidget {
  8. @override
  9. Widget build(BuildContext context) {
  10. return MaterialApp(
  11. title: 'Flutter Demo',
  12. theme: ThemeData(
  13. primarySwatch: Colors.blue,
  14. ),
  15. home: MyHomePage(),
  16. );
  17. }
  18. }
  19.  
  20. class MyHomePage extends StatefulWidget {
  21. @override
  22. _MyHomePageState createState() => _MyHomePageState();
  23. }
  24.  
  25. class _MyHomePageState extends State<MyHomePage> {
  26. int _counter = 0;
  27.  
  28. void _incrementCounter() {
  29. setState(() {
  30. _counter++;
  31. });
  32. }
  33.  
  34. @override
  35. Widget build(BuildContext context) {
  36. return Scaffold(
  37. appBar: AppBar(
  38. title: Text("Flutter App Example"),
  39. ),
  40. body: Center(
  41. child: Column(
  42. mainAxisAlignment: MainAxisAlignment.center,
  43. children: <Widget>[
  44. Text(
  45. 'You have pushed the button this many times:',
  46. ),
  47. Text(
  48. '$_counter',
  49. style: Theme.of(context).textTheme.headline4,
  50. ),
  51. ],
  52. ),
  53. ),
  54. floatingActionButton: FloatingActionButton(
  55. onPressed: _incrementCounter,
  56. tooltip: 'Increment',
  57. child: Icon(Icons.add),
  58. ),
  59. );
  60. }
  61. }
  62.  
Success #stdin #stdout 0.02s 25768KB
stdin
Standard input is empty
stdout
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Flutter App Example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}