import 'package:english_words/english_words.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) => MyAppState(), child: MaterialApp( title: 'Namer App', theme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange), ), home: MyHomePage(), ), ); } } class MyAppState extends ChangeNotifier { var rows = 3; var dance = { "instructions": [ ["call"], ["call2"] ] }; void addCall(call) { dance["instructions"]?[0].add(call); notifyListeners(); } } class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { var appState = context.watch(); var rowElements = []; var instructions = appState.dance["instructions"]; if (instructions != null) { for (var row in instructions) { rowElements.add(Row( mainAxisAlignment: MainAxisAlignment.center, children: row.map((e) => Text(e)).toList())); } } return Scaffold( body: Column( children: [...rowElements, AddCall(appState: appState)], ), ); } } class AddCall extends StatelessWidget { const AddCall({ super.key, required this.appState, }); final MyAppState appState; @override Widget build(BuildContext context) { return ElevatedButton( onPressed: () => appState.addCall("hello world"), child: Text("buttonText"), ); } }