// 1) Create a new Flutter App (in this project) and output an AppBar and some text // below it // 2) Add a button which changes the text (to any other text of your choice) // 3) Split the app into three widgets: App, TextControl & Text import 'package:flutter/material.dart'; import './text_title.dart'; import './click_button.dart'; void main() => runApp(const MyApp()); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override State createState() => _MyAppState(); } class _MyAppState extends State { static const List _titles = [ 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', ]; int _titleIndex = 0; void _changeText() { setState(() { _titleIndex += 1; if (_titleIndex >= _titles.length) { _titleIndex = 0; } }); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Flutter Assignment 1'), ), body: Center( child: Column( children: [ TestTitle(title: _titles[_titleIndex]), ClickButton(onPressedHandler: _changeText), ], ), ), ), ); } }