Last active
June 19, 2019 21:31
-
-
Save aneury1/c15c38b60a340bc6f87b5f0771be6914 to your computer and use it in GitHub Desktop.
This file contains 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
import 'package:flutter/material.dart'; | |
void main() => runApp(RealApp()); | |
class RealApp extends StatelessWidget{ | |
@override | |
Widget build(BuildContext context) { | |
return MyApp(); | |
} | |
} | |
class MyApp extends StatefulWidget{ | |
@override | |
_defaultState createState() => _defaultState(); | |
} | |
class _defaultState extends State<MyApp>{ | |
int counter =0; | |
void incrementCounter() => setState((){counter++;}); | |
void decrementCounter() => setState((){counter--;}); | |
void doubleCounter() => setState((){counter*=2;}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Learn Flutter', | |
home: Scaffold( | |
appBar: _WidgetBuilder.getAppBar(this), | |
body: Center( | |
child: Text('counter ${this.counter}'), | |
), | |
), | |
); | |
} | |
} | |
class _WidgetBuilder { | |
static getAppBar(_defaultState obj) { | |
return AppBar( | |
leading: IconButton( | |
icon: Icon(Icons.playlist_play), | |
tooltip: 'Air it', | |
onPressed: (){obj.incrementCounter();}, | |
), | |
title: Text('State'), | |
actions: <Widget>[ | |
Center(child: Text("esto")), | |
IconButton( | |
icon: Icon(Icons.playlist_play), | |
tooltip: 'Air it', | |
onPressed: () { | |
print('\u{1f600}'); | |
(){obj.doubleCounter();}(); | |
}, | |
), | |
IconButton( | |
icon: Icon(Icons.playlist_add), | |
tooltip: 'Restitch it', | |
onPressed: (){obj.decrementCounter();} | |
), | |
IconButton( | |
icon: Icon(Icons.playlist_add_check), | |
tooltip: 'Repair it', | |
onPressed: null, | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
throw an exception, find it.!!