loloof64

Flutter assignment #1

Feb 11th, 2021
651
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(App());
  5. }
  6.  
  7. class App extends StatelessWidget {
  8.   @override
  9.   Widget build(BuildContext context) {
  10.     return MaterialApp(
  11.       home: Scaffold(
  12.           appBar: AppBar(
  13.             title: Text('My fun app'),
  14.           ),
  15.           body: TextWidget()),
  16.     );
  17.   }
  18. }
  19.  
  20. class TextWidget extends StatefulWidget {
  21.   @override
  22.   _TextWidgetState createState() => _TextWidgetState();
  23. }
  24.  
  25. class _TextWidgetState extends State<TextWidget> {
  26.  
  27.   var _text = 'Hello';
  28.  
  29.   void _changeText() {
  30.     setState(() {
  31.       _text = 'How are you ?';
  32.     });
  33.   }
  34.  
  35.   @override
  36.   Widget build(BuildContext context) {
  37.     return Column(children: <Widget>[
  38.       Text(_text),
  39.       TextController('Change text', _changeText)
  40.     ]);
  41.   }
  42. }
  43.  
  44.  
  45. class TextController extends StatelessWidget {
  46.  
  47.   final String _label;
  48.   final Function _changeHandler;
  49.  
  50.   TextController(this._label, this._changeHandler);
  51.  
  52.   @override
  53.   Widget build(BuildContext context) {
  54.     return RaisedButton(onPressed: _changeHandler, child: Text(_label),);
  55.   }
  56. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×