callerkit/lib/main.dart
PAlexanderFranklin 7d84bac493 Add package
2023-10-01 02:11:57 -07:00

82 lines
1.8 KiB
Dart

import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'navbar/navbar.dart';
void main() {
runApp(const 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<MyAppState>();
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), Navbar()],
),
);
}
}
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: const Text("buttonText"),
);
}
}