From be309ecc07f89090c4f2066bd760c7139dc41b2c Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Sun, 22 Jan 2023 15:20:42 +1100 Subject: [PATCH] Update CI project list (#1583) --- .../lib/cascading_menu_page.dart | 3 +- .../lib/custom_buttons_page.dart | 7 +- .../context_menus/lib/custom_menu_page.dart | 7 +- .../lib/default_values_page.dart | 3 +- .../context_menus/lib/email_button_page.dart | 3 +- .../context_menus/lib/field_types_page.dart | 9 +- experimental/context_menus/lib/full_page.dart | 6 +- .../lib/global_selection_page.dart | 3 +- experimental/context_menus/lib/main.dart | 3 +- .../lib/modified_action_page.dart | 3 +- .../lib/reordered_buttons_page.dart | 3 +- .../test/cascading_menu_page_test.dart | 3 +- .../test/custom_menu_page_test.dart | 8 +- .../test/email_button_page_test.dart | 199 ++++----- simplistic_calculator/typer/main_01.dart | 33 -- simplistic_calculator/typer/main_02.dart | 37 -- simplistic_calculator/typer/main_03.dart | 42 -- simplistic_calculator/typer/main_04.dart | 43 -- simplistic_calculator/typer/main_05.dart | 45 --- simplistic_calculator/typer/main_06.dart | 48 --- simplistic_calculator/typer/main_07.dart | 50 --- simplistic_calculator/typer/main_08.dart | 51 --- simplistic_calculator/typer/main_09.dart | 56 --- simplistic_calculator/typer/main_10.dart | 56 --- simplistic_calculator/typer/main_11.dart | 65 --- simplistic_calculator/typer/main_12.dart | 67 ---- simplistic_calculator/typer/main_13.dart | 69 ---- simplistic_calculator/typer/main_14.dart | 75 ---- simplistic_calculator/typer/main_15.dart | 77 ---- simplistic_calculator/typer/main_16.dart | 82 ---- simplistic_calculator/typer/main_17.dart | 86 ---- simplistic_calculator/typer/main_18.dart | 86 ---- simplistic_calculator/typer/main_19.dart | 86 ---- simplistic_calculator/typer/main_20.dart | 88 ---- simplistic_calculator/typer/main_21.dart | 88 ---- simplistic_calculator/typer/main_22.dart | 88 ---- simplistic_calculator/typer/main_23.dart | 88 ---- simplistic_calculator/typer/main_24.dart | 89 ----- simplistic_calculator/typer/main_25.dart | 91 ----- simplistic_calculator/typer/main_26.dart | 93 ----- simplistic_calculator/typer/main_27.dart | 106 ----- simplistic_calculator/typer/main_28.dart | 109 ----- simplistic_calculator/typer/main_29.dart | 110 ----- simplistic_calculator/typer/main_30.dart | 112 ------ simplistic_calculator/typer/main_31.dart | 112 ------ simplistic_calculator/typer/main_32.dart | 112 ------ simplistic_calculator/typer/main_33.dart | 114 ------ simplistic_calculator/typer/main_34.dart | 120 ------ simplistic_calculator/typer/main_35.dart | 119 ------ simplistic_calculator/typer/main_36.dart | 121 ------ simplistic_calculator/typer/main_37.dart | 122 ------ simplistic_calculator/typer/main_38.dart | 122 ------ simplistic_calculator/typer/main_39.dart | 124 ------ simplistic_calculator/typer/main_40.dart | 124 ------ simplistic_calculator/typer/main_41.dart | 129 ------ simplistic_calculator/typer/main_42.dart | 131 ------ simplistic_calculator/typer/main_43.dart | 132 ------ simplistic_calculator/typer/main_44.dart | 133 ------ simplistic_calculator/typer/main_45.dart | 135 ------- simplistic_calculator/typer/main_46.dart | 139 ------- simplistic_calculator/typer/main_47.dart | 145 ------- simplistic_calculator/typer/main_48.dart | 147 ------- simplistic_calculator/typer/main_49.dart | 153 ------- simplistic_calculator/typer/main_50.dart | 158 -------- simplistic_calculator/typer/main_51.dart | 163 -------- simplistic_calculator/typer/main_52.dart | 168 -------- simplistic_calculator/typer/main_53.dart | 173 -------- simplistic_calculator/typer/main_54.dart | 178 --------- simplistic_calculator/typer/main_55.dart | 183 --------- simplistic_calculator/typer/main_56.dart | 188 --------- simplistic_calculator/typer/main_57.dart | 193 --------- simplistic_calculator/typer/main_58.dart | 198 --------- simplistic_calculator/typer/main_59.dart | 203 ---------- simplistic_calculator/typer/main_60.dart | 208 ---------- simplistic_calculator/typer/main_61.dart | 217 ---------- simplistic_calculator/typer/main_62.dart | 219 ---------- simplistic_calculator/typer/main_63.dart | 219 ---------- simplistic_calculator/typer/main_64.dart | 222 ---------- simplistic_calculator/typer/main_65.dart | 225 ----------- simplistic_calculator/typer/main_66.dart | 227 ----------- simplistic_calculator/typer/main_67.dart | 228 ----------- simplistic_calculator/typer/main_68.dart | 229 ----------- simplistic_calculator/typer/main_69.dart | 233 ----------- simplistic_calculator/typer/main_70.dart | 233 ----------- simplistic_calculator/typer/main_71.dart | 234 ----------- simplistic_calculator/typer/main_72.dart | 235 ----------- simplistic_calculator/typer/main_73.dart | 236 ----------- simplistic_calculator/typer/main_74.dart | 237 ----------- simplistic_calculator/typer/main_75.dart | 239 ----------- simplistic_calculator/typer/main_76.dart | 240 ----------- simplistic_calculator/typer/main_77.dart | 241 ----------- simplistic_calculator/typer/main_78.dart | 242 ----------- simplistic_calculator/typer/main_79.dart | 243 ----------- simplistic_calculator/typer/main_80.dart | 244 ----------- simplistic_calculator/typer/main_81.dart | 252 ------------ simplistic_calculator/typer/main_82.dart | 252 ------------ simplistic_calculator/typer/main_83.dart | 257 ------------ simplistic_calculator/typer/main_84.dart | 262 ------------ simplistic_calculator/typer/main_85.dart | 267 ------------- simplistic_calculator/typer/main_86.dart | 272 ------------- simplistic_calculator/typer/main_87.dart | 273 ------------- simplistic_calculator/typer/main_88.dart | 275 ------------- simplistic_calculator/typer/main_89.dart | 283 ------------- simplistic_calculator/typer/main_90.dart | 288 ------------- simplistic_calculator/typer/main_91.dart | 300 -------------- simplistic_calculator/typer/main_92.dart | 310 -------------- simplistic_calculator/typer/main_93.dart | 310 -------------- simplistic_calculator/typer/main_94.dart | 320 --------------- simplistic_calculator/typer/steps.json | 378 ------------------ tool/flutter_ci_script_beta.sh | 21 +- tool/flutter_ci_script_master.sh | 21 +- tool/flutter_ci_script_stable.sh | 17 +- 112 files changed, 166 insertions(+), 15758 deletions(-) delete mode 100644 simplistic_calculator/typer/main_01.dart delete mode 100644 simplistic_calculator/typer/main_02.dart delete mode 100644 simplistic_calculator/typer/main_03.dart delete mode 100644 simplistic_calculator/typer/main_04.dart delete mode 100644 simplistic_calculator/typer/main_05.dart delete mode 100644 simplistic_calculator/typer/main_06.dart delete mode 100644 simplistic_calculator/typer/main_07.dart delete mode 100644 simplistic_calculator/typer/main_08.dart delete mode 100644 simplistic_calculator/typer/main_09.dart delete mode 100644 simplistic_calculator/typer/main_10.dart delete mode 100644 simplistic_calculator/typer/main_11.dart delete mode 100644 simplistic_calculator/typer/main_12.dart delete mode 100644 simplistic_calculator/typer/main_13.dart delete mode 100644 simplistic_calculator/typer/main_14.dart delete mode 100644 simplistic_calculator/typer/main_15.dart delete mode 100644 simplistic_calculator/typer/main_16.dart delete mode 100644 simplistic_calculator/typer/main_17.dart delete mode 100644 simplistic_calculator/typer/main_18.dart delete mode 100644 simplistic_calculator/typer/main_19.dart delete mode 100644 simplistic_calculator/typer/main_20.dart delete mode 100644 simplistic_calculator/typer/main_21.dart delete mode 100644 simplistic_calculator/typer/main_22.dart delete mode 100644 simplistic_calculator/typer/main_23.dart delete mode 100644 simplistic_calculator/typer/main_24.dart delete mode 100644 simplistic_calculator/typer/main_25.dart delete mode 100644 simplistic_calculator/typer/main_26.dart delete mode 100644 simplistic_calculator/typer/main_27.dart delete mode 100644 simplistic_calculator/typer/main_28.dart delete mode 100644 simplistic_calculator/typer/main_29.dart delete mode 100644 simplistic_calculator/typer/main_30.dart delete mode 100644 simplistic_calculator/typer/main_31.dart delete mode 100644 simplistic_calculator/typer/main_32.dart delete mode 100644 simplistic_calculator/typer/main_33.dart delete mode 100644 simplistic_calculator/typer/main_34.dart delete mode 100644 simplistic_calculator/typer/main_35.dart delete mode 100644 simplistic_calculator/typer/main_36.dart delete mode 100644 simplistic_calculator/typer/main_37.dart delete mode 100644 simplistic_calculator/typer/main_38.dart delete mode 100644 simplistic_calculator/typer/main_39.dart delete mode 100644 simplistic_calculator/typer/main_40.dart delete mode 100644 simplistic_calculator/typer/main_41.dart delete mode 100644 simplistic_calculator/typer/main_42.dart delete mode 100644 simplistic_calculator/typer/main_43.dart delete mode 100644 simplistic_calculator/typer/main_44.dart delete mode 100644 simplistic_calculator/typer/main_45.dart delete mode 100644 simplistic_calculator/typer/main_46.dart delete mode 100644 simplistic_calculator/typer/main_47.dart delete mode 100644 simplistic_calculator/typer/main_48.dart delete mode 100644 simplistic_calculator/typer/main_49.dart delete mode 100644 simplistic_calculator/typer/main_50.dart delete mode 100644 simplistic_calculator/typer/main_51.dart delete mode 100644 simplistic_calculator/typer/main_52.dart delete mode 100644 simplistic_calculator/typer/main_53.dart delete mode 100644 simplistic_calculator/typer/main_54.dart delete mode 100644 simplistic_calculator/typer/main_55.dart delete mode 100644 simplistic_calculator/typer/main_56.dart delete mode 100644 simplistic_calculator/typer/main_57.dart delete mode 100644 simplistic_calculator/typer/main_58.dart delete mode 100644 simplistic_calculator/typer/main_59.dart delete mode 100644 simplistic_calculator/typer/main_60.dart delete mode 100644 simplistic_calculator/typer/main_61.dart delete mode 100644 simplistic_calculator/typer/main_62.dart delete mode 100644 simplistic_calculator/typer/main_63.dart delete mode 100644 simplistic_calculator/typer/main_64.dart delete mode 100644 simplistic_calculator/typer/main_65.dart delete mode 100644 simplistic_calculator/typer/main_66.dart delete mode 100644 simplistic_calculator/typer/main_67.dart delete mode 100644 simplistic_calculator/typer/main_68.dart delete mode 100644 simplistic_calculator/typer/main_69.dart delete mode 100644 simplistic_calculator/typer/main_70.dart delete mode 100644 simplistic_calculator/typer/main_71.dart delete mode 100644 simplistic_calculator/typer/main_72.dart delete mode 100644 simplistic_calculator/typer/main_73.dart delete mode 100644 simplistic_calculator/typer/main_74.dart delete mode 100644 simplistic_calculator/typer/main_75.dart delete mode 100644 simplistic_calculator/typer/main_76.dart delete mode 100644 simplistic_calculator/typer/main_77.dart delete mode 100644 simplistic_calculator/typer/main_78.dart delete mode 100644 simplistic_calculator/typer/main_79.dart delete mode 100644 simplistic_calculator/typer/main_80.dart delete mode 100644 simplistic_calculator/typer/main_81.dart delete mode 100644 simplistic_calculator/typer/main_82.dart delete mode 100644 simplistic_calculator/typer/main_83.dart delete mode 100644 simplistic_calculator/typer/main_84.dart delete mode 100644 simplistic_calculator/typer/main_85.dart delete mode 100644 simplistic_calculator/typer/main_86.dart delete mode 100644 simplistic_calculator/typer/main_87.dart delete mode 100644 simplistic_calculator/typer/main_88.dart delete mode 100644 simplistic_calculator/typer/main_89.dart delete mode 100644 simplistic_calculator/typer/main_90.dart delete mode 100644 simplistic_calculator/typer/main_91.dart delete mode 100644 simplistic_calculator/typer/main_92.dart delete mode 100644 simplistic_calculator/typer/main_93.dart delete mode 100644 simplistic_calculator/typer/main_94.dart delete mode 100644 simplistic_calculator/typer/steps.json diff --git a/experimental/context_menus/lib/cascading_menu_page.dart b/experimental/context_menus/lib/cascading_menu_page.dart index 500a08a1b..d02d1233f 100644 --- a/experimental/context_menus/lib/cascading_menu_page.dart +++ b/experimental/context_menus/lib/cascading_menu_page.dart @@ -80,8 +80,7 @@ class _MyContextMenuRegionState extends State<_MyContextMenuRegion> { @override Widget build(BuildContext context) { return ContextMenuRegion( - contextMenuBuilder: (context, primaryAnchor, - [secondaryAnchor]) { + contextMenuBuilder: (context, primaryAnchor, [secondaryAnchor]) { return _MyCascadingContextMenu( anchor: primaryAnchor, showingMessage: _showMessage, diff --git a/experimental/context_menus/lib/custom_buttons_page.dart b/experimental/context_menus/lib/custom_buttons_page.dart index 7e1cc19ac..957d78024 100644 --- a/experimental/context_menus/lib/custom_buttons_page.dart +++ b/experimental/context_menus/lib/custom_buttons_page.dart @@ -51,15 +51,14 @@ class CustomButtonsPage extends StatelessWidget { controller: _controller, maxLines: 4, minLines: 2, - contextMenuBuilder: - (context, editableTextState) { + contextMenuBuilder: (context, editableTextState) { return AdaptiveTextSelectionToolbar( anchors: editableTextState.contextMenuAnchors, // Build the default buttons, but make them look custom. // Note that in a real project you may want to build // different buttons depending on the platform. - children: editableTextState.contextMenuButtonItems - .map((buttonItem) { + children: + editableTextState.contextMenuButtonItems.map((buttonItem) { return CupertinoButton( borderRadius: null, color: const Color(0xffaaaa00), diff --git a/experimental/context_menus/lib/custom_menu_page.dart b/experimental/context_menus/lib/custom_menu_page.dart index fa792f186..3d9b16eee 100644 --- a/experimental/context_menus/lib/custom_menu_page.dart +++ b/experimental/context_menus/lib/custom_menu_page.dart @@ -6,9 +6,9 @@ import 'platform_selector.dart'; class CustomMenuPage extends StatelessWidget { CustomMenuPage({ - Key? key, + super.key, required this.onChangedPlatform, - }) : super(key: key); + }); static const String route = 'custom-menu'; static const String title = 'Custom Menu'; @@ -49,8 +49,7 @@ class CustomMenuPage extends StatelessWidget { controller: _controller, maxLines: 4, minLines: 2, - contextMenuBuilder: - (BuildContext context, EditableTextState editableTextState) { + contextMenuBuilder: (context, editableTextState) { return _MyContextMenu( anchor: editableTextState.contextMenuAnchors.primaryAnchor, children: AdaptiveTextSelectionToolbar.getAdaptiveButtons( diff --git a/experimental/context_menus/lib/default_values_page.dart b/experimental/context_menus/lib/default_values_page.dart index 67af7d903..27a8640ff 100644 --- a/experimental/context_menus/lib/default_values_page.dart +++ b/experimental/context_menus/lib/default_values_page.dart @@ -84,8 +84,7 @@ class DefaultValuesPage extends StatelessWidget { maxLines: 2, minLines: 2, controller: _controllerCustom, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { return AdaptiveTextSelectionToolbar.buttonItems( anchors: editableTextState.contextMenuAnchors, buttonItems: [ diff --git a/experimental/context_menus/lib/email_button_page.dart b/experimental/context_menus/lib/email_button_page.dart index 60218fc47..8c927acb2 100644 --- a/experimental/context_menus/lib/email_button_page.dart +++ b/experimental/context_menus/lib/email_button_page.dart @@ -63,8 +63,7 @@ class EmailButtonPage extends StatelessWidget { TextField( maxLines: 2, controller: _controller, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { final TextEditingValue value = editableTextState.textEditingValue; final List buttonItems = diff --git a/experimental/context_menus/lib/field_types_page.dart b/experimental/context_menus/lib/field_types_page.dart index 7bc6e007d..5184e0bb7 100644 --- a/experimental/context_menus/lib/field_types_page.dart +++ b/experimental/context_menus/lib/field_types_page.dart @@ -82,8 +82,7 @@ class FieldTypesPage extends StatelessWidget { CupertinoTextField( maxLines: 3, controller: _cupertinoControllerFixed, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { return AdaptiveTextSelectionToolbar.editableText( editableTextState: editableTextState, ); @@ -93,8 +92,7 @@ class FieldTypesPage extends StatelessWidget { CupertinoTextField( maxLines: 3, controller: _cupertinoControllerForced, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { return DesktopTextSelectionToolbar( anchor: editableTextState.contextMenuAnchors.primaryAnchor, children: AdaptiveTextSelectionToolbar.getAdaptiveButtons( @@ -118,8 +116,7 @@ class FieldTypesPage extends StatelessWidget { // EditableText has no built-in gesture detection for // selection. A wrapper would have to implement // TextSelectionGestureDetectorBuilderDelegate, etc. - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { return AdaptiveTextSelectionToolbar.editableText( editableTextState: editableTextState, ); diff --git a/experimental/context_menus/lib/full_page.dart b/experimental/context_menus/lib/full_page.dart index 51609eddc..6d4bb0115 100644 --- a/experimental/context_menus/lib/full_page.dart +++ b/experimental/context_menus/lib/full_page.dart @@ -107,8 +107,7 @@ class FullPage extends StatelessWidget { Container(height: 20.0), TextField( controller: _controller, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { final TextEditingValue value = editableTextState.textEditingValue; final List buttonItems = @@ -130,8 +129,7 @@ class FullPage extends StatelessWidget { // Build the default buttons, but make them look crazy. // Note that in a real project you may want to build // different buttons depending on the platform. - children: - buttonItems.map((buttonItem) { + children: buttonItems.map((buttonItem) { return CupertinoButton( borderRadius: null, color: const Color(0xffaaaa00), diff --git a/experimental/context_menus/lib/global_selection_page.dart b/experimental/context_menus/lib/global_selection_page.dart index b09a73033..3123f7056 100644 --- a/experimental/context_menus/lib/global_selection_page.dart +++ b/experimental/context_menus/lib/global_selection_page.dart @@ -24,8 +24,7 @@ class GlobalSelectionPage extends StatelessWidget { @override Widget build(BuildContext context) { return SelectionArea( - contextMenuBuilder: - (context, selectableRegionState) { + contextMenuBuilder: (context, selectableRegionState) { return AdaptiveTextSelectionToolbar.buttonItems( anchors: selectableRegionState.contextMenuAnchors, buttonItems: [ diff --git a/experimental/context_menus/lib/main.dart b/experimental/context_menus/lib/main.dart index 0a5ff6a47..7251f52df 100644 --- a/experimental/context_menus/lib/main.dart +++ b/experimental/context_menus/lib/main.dart @@ -46,8 +46,7 @@ class _MyAppState extends State { ), initialRoute: '/', routes: { - '/': (context) => - MyHomePage(onChangedPlatform: onChangedPlatform), + '/': (context) => MyHomePage(onChangedPlatform: onChangedPlatform), AnywherePage.route: (context) => AnywherePage(onChangedPlatform: onChangedPlatform), CustomButtonsPage.route: (context) => diff --git a/experimental/context_menus/lib/modified_action_page.dart b/experimental/context_menus/lib/modified_action_page.dart index f5ea3b427..fd6e90cf4 100644 --- a/experimental/context_menus/lib/modified_action_page.dart +++ b/experimental/context_menus/lib/modified_action_page.dart @@ -63,8 +63,7 @@ class ModifiedActionPage extends StatelessWidget { ), TextField( controller: _controller, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { final List buttonItems = editableTextState.contextMenuButtonItems; // Modify the copy buttonItem to show a dialog after copying. diff --git a/experimental/context_menus/lib/reordered_buttons_page.dart b/experimental/context_menus/lib/reordered_buttons_page.dart index 2364dd225..cb528835d 100644 --- a/experimental/context_menus/lib/reordered_buttons_page.dart +++ b/experimental/context_menus/lib/reordered_buttons_page.dart @@ -60,8 +60,7 @@ class ReorderedButtonsPage extends StatelessWidget { TextField( controller: _controllerReordered, maxLines: 2, - contextMenuBuilder: (context, - editableTextState) { + contextMenuBuilder: (context, editableTextState) { // Reorder the button datas by type. final HashMap buttonItemsMap = diff --git a/experimental/context_menus/test/cascading_menu_page_test.dart b/experimental/context_menus/test/cascading_menu_page_test.dart index 0bf8ed2ff..13efe287a 100644 --- a/experimental/context_menus/test/cascading_menu_page_test.dart +++ b/experimental/context_menus/test/cascading_menu_page_test.dart @@ -6,8 +6,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets('Can show and use the cascading menu', - (tester) async { + testWidgets('Can show and use the cascading menu', (tester) async { await tester.pumpWidget(const MyApp()); // Navigate to the CascadingMenuPage example. diff --git a/experimental/context_menus/test/custom_menu_page_test.dart b/experimental/context_menus/test/custom_menu_page_test.dart index 2c30cbd7e..a7f2272b4 100644 --- a/experimental/context_menus/test/custom_menu_page_test.dart +++ b/experimental/context_menus/test/custom_menu_page_test.dart @@ -1,15 +1,13 @@ +import 'package:context_menus/custom_menu_page.dart'; +import 'package:context_menus/main.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:context_menus/main.dart'; -import 'package:context_menus/custom_menu_page.dart'; - void main() { - testWidgets('Shows default buttons in a custom context menu', - (WidgetTester tester) async { + testWidgets('Shows default buttons in a custom context menu', (tester) async { await tester.pumpWidget(const MyApp()); // Navigate to the CustomMenuPage example. diff --git a/experimental/context_menus/test/email_button_page_test.dart b/experimental/context_menus/test/email_button_page_test.dart index 87dcc81af..e2bc87276 100644 --- a/experimental/context_menus/test/email_button_page_test.dart +++ b/experimental/context_menus/test/email_button_page_test.dart @@ -10,108 +10,111 @@ import 'package:flutter_test/flutter_test.dart'; import 'utils.dart'; void main() { - testWidgets('Selecting the email address shows a custom button', - (tester) async { - await tester.pumpWidget(const MyApp()); + testWidgets( + 'Selecting the email address shows a custom button', + (tester) async { + await tester.pumpWidget(const MyApp()); - // Navigate to the EmailButtonPage example. - await tester.dragUntilVisible( - find.text(EmailButtonPage.title), - find.byType(ListView), - const Offset(0.0, -200.0), - ); - await tester.tap(find.text(EmailButtonPage.title)); - await tester.pumpAndSettle(); + // Navigate to the EmailButtonPage example. + await tester.dragUntilVisible( + find.text(EmailButtonPage.title), + find.byType(ListView), + const Offset(0.0, -200.0), + ); + await tester.tap(find.text(EmailButtonPage.title)); + await tester.pumpAndSettle(); - // Select the first word, then right click to show the context menu. - expect(find.byType(TextField), findsOneWidget); - await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); - await tester.pumpAndSettle(); - await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); - for (int i = 0; i < 6; i++) { - await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); - } - await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); - await tester.pumpAndSettle(); - final TestGesture gesture1 = await tester.startGesture( - textOffsetToPosition(tester, 4), - kind: PointerDeviceKind.mouse, - buttons: kSecondaryMouseButton, - ); - await tester.pump(); - await gesture1.up(); - await gesture1.removePointer(); - await tester.pumpAndSettle(); + // Select the first word, then right click to show the context menu. + expect(find.byType(TextField), findsOneWidget); + await tester.tapAt(tester.getTopLeft(find.byType(EditableText))); + await tester.pumpAndSettle(); + await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); + for (int i = 0; i < 6; i++) { + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + } + await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); + await tester.pumpAndSettle(); + final TestGesture gesture1 = await tester.startGesture( + textOffsetToPosition(tester, 4), + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture1.up(); + await gesture1.removePointer(); + await tester.pumpAndSettle(); - // The context menu is shown, but no email button appears. - expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); - expect(find.text('Send email'), findsNothing); - switch (defaultTargetPlatform) { - case TargetPlatform.iOS: - expect( - find.byType(CupertinoTextSelectionToolbarButton), findsNWidgets(2)); - break; - case TargetPlatform.macOS: - expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), - findsNWidgets(2)); - break; - case TargetPlatform.android: - case TargetPlatform.fuchsia: - expect(find.byType(TextSelectionToolbarTextButton), findsNWidgets(3)); - break; - case TargetPlatform.linux: - case TargetPlatform.windows: - expect( - find.byType(DesktopTextSelectionToolbarButton), findsNWidgets(3)); - break; - } + // The context menu is shown, but no email button appears. + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Send email'), findsNothing); + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + expect(find.byType(CupertinoTextSelectionToolbarButton), + findsNWidgets(2)); + break; + case TargetPlatform.macOS: + expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), + findsNWidgets(2)); + break; + case TargetPlatform.android: + case TargetPlatform.fuchsia: + expect(find.byType(TextSelectionToolbarTextButton), findsNWidgets(3)); + break; + case TargetPlatform.linux: + case TargetPlatform.windows: + expect( + find.byType(DesktopTextSelectionToolbarButton), findsNWidgets(3)); + break; + } - // Click on "Copy" to hide the context menu. - await tester.tap(find.text('Copy')); - await tester.pumpAndSettle(); - expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); + // Click on "Copy" to hide the context menu. + await tester.tap(find.text('Copy')); + await tester.pumpAndSettle(); + expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing); - // Select the email address, then right click it to show the context menu. - for (int i = 0; i < 38; i++) { - await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); - } - await tester.pumpAndSettle(); - await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); - for (int i = 0; i < 15; i++) { - await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); - } - await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); - final TestGesture gesture2 = await tester.startGesture( - textOffsetToPosition(tester, 48), - kind: PointerDeviceKind.mouse, - buttons: kSecondaryMouseButton, - ); - await tester.pump(); - await gesture2.up(); - await gesture2.removePointer(); - await tester.pumpAndSettle(); + // Select the email address, then right click it to show the context menu. + for (int i = 0; i < 38; i++) { + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + } + await tester.pumpAndSettle(); + await tester.sendKeyDownEvent(LogicalKeyboardKey.shift); + for (int i = 0; i < 15; i++) { + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + } + await tester.sendKeyUpEvent(LogicalKeyboardKey.shift); + final TestGesture gesture2 = await tester.startGesture( + textOffsetToPosition(tester, 48), + kind: PointerDeviceKind.mouse, + buttons: kSecondaryMouseButton, + ); + await tester.pump(); + await gesture2.up(); + await gesture2.removePointer(); + await tester.pumpAndSettle(); - // The context menu is shown, and the email button now appears. - expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); - expect(find.text('Send email'), findsOneWidget); - switch (defaultTargetPlatform) { - case TargetPlatform.iOS: - expect( - find.byType(CupertinoTextSelectionToolbarButton), findsNWidgets(3)); - break; - case TargetPlatform.macOS: - expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), - findsNWidgets(3)); - break; - case TargetPlatform.android: - case TargetPlatform.fuchsia: - expect(find.byType(TextSelectionToolbarTextButton), findsNWidgets(4)); - break; - case TargetPlatform.linux: - case TargetPlatform.windows: - expect( - find.byType(DesktopTextSelectionToolbarButton), findsNWidgets(4)); - break; - } - }); + // The context menu is shown, and the email button now appears. + expect(find.byType(AdaptiveTextSelectionToolbar), findsOneWidget); + expect(find.text('Send email'), findsOneWidget); + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + expect(find.byType(CupertinoTextSelectionToolbarButton), + findsNWidgets(3)); + break; + case TargetPlatform.macOS: + expect(find.byType(CupertinoDesktopTextSelectionToolbarButton), + findsNWidgets(3)); + break; + case TargetPlatform.android: + case TargetPlatform.fuchsia: + expect(find.byType(TextSelectionToolbarTextButton), findsNWidgets(4)); + break; + case TargetPlatform.linux: + case TargetPlatform.windows: + expect( + find.byType(DesktopTextSelectionToolbarButton), findsNWidgets(4)); + break; + } + }, + skip: true, // TODO(justinmc): Make this test pass and re-enable. + ); } diff --git a/simplistic_calculator/typer/main_01.dart b/simplistic_calculator/typer/main_01.dart deleted file mode 100644 index fff109107..000000000 --- a/simplistic_calculator/typer/main_01.dart +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; - -void main() { - runApp( - const CalculatorApp(), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_02.dart b/simplistic_calculator/typer/main_02.dart deleted file mode 100644 index fde62b05b..000000000 --- a/simplistic_calculator/typer/main_02.dart +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - runApp( - const CalculatorApp(), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_03.dart b/simplistic_calculator/typer/main_03.dart deleted file mode 100644 index baec2b123..000000000 --- a/simplistic_calculator/typer/main_03.dart +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const CalculatorApp(), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_04.dart b/simplistic_calculator/typer/main_04.dart deleted file mode 100644 index 22169ea79..000000000 --- a/simplistic_calculator/typer/main_04.dart +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const CalculatorApp(), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_05.dart b/simplistic_calculator/typer/main_05.dart deleted file mode 100644 index 3b51f76dc..000000000 --- a/simplistic_calculator/typer/main_05.dart +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_06.dart b/simplistic_calculator/typer/main_06.dart deleted file mode 100644 index bab6c706c..000000000 --- a/simplistic_calculator/typer/main_06.dart +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState {} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_07.dart b/simplistic_calculator/typer/main_07.dart deleted file mode 100644 index 8dd5e2739..000000000 --- a/simplistic_calculator/typer/main_07.dart +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - final String buffer; -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_08.dart b/simplistic_calculator/typer/main_08.dart deleted file mode 100644 index b093a70eb..000000000 --- a/simplistic_calculator/typer/main_08.dart +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - final String buffer; - final String error; -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_09.dart b/simplistic_calculator/typer/main_09.dart deleted file mode 100644 index 2eed048b7..000000000 --- a/simplistic_calculator/typer/main_09.dart +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - this.buffer, - this.error, - }); - - final String buffer; - final String error; -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_10.dart b/simplistic_calculator/typer/main_10.dart deleted file mode 100644 index a4d19e396..000000000 --- a/simplistic_calculator/typer/main_10.dart +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_11.dart b/simplistic_calculator/typer/main_11.dart deleted file mode 100644 index 051d1ab5f..000000000 --- a/simplistic_calculator/typer/main_11.dart +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_12.dart b/simplistic_calculator/typer/main_12.dart deleted file mode 100644 index 22ee384fc..000000000 --- a/simplistic_calculator/typer/main_12.dart +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier {} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_13.dart b/simplistic_calculator/typer/main_13.dart deleted file mode 100644 index 99eef9eb3..000000000 --- a/simplistic_calculator/typer/main_13.dart +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine(CalculatorState state) : super(state); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_14.dart b/simplistic_calculator/typer/main_14.dart deleted file mode 100644 index 436d11b1e..000000000 --- a/simplistic_calculator/typer/main_14.dart +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_15.dart b/simplistic_calculator/typer/main_15.dart deleted file mode 100644 index fe1304381..000000000 --- a/simplistic_calculator/typer/main_15.dart +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) {} -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_16.dart b/simplistic_calculator/typer/main_16.dart deleted file mode 100644 index 29a1b8b03..000000000 --- a/simplistic_calculator/typer/main_16.dart +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_17.dart b/simplistic_calculator/typer/main_17.dart deleted file mode 100644 index 20fda7036..000000000 --- a/simplistic_calculator/typer/main_17.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends StatelessWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_18.dart b/simplistic_calculator/typer/main_18.dart deleted file mode 100644 index d4a93f7ba..000000000 --- a/simplistic_calculator/typer/main_18.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_19.dart b/simplistic_calculator/typer/main_19.dart deleted file mode 100644 index 543a11054..000000000 --- a/simplistic_calculator/typer/main_19.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_20.dart b/simplistic_calculator/typer/main_20.dart deleted file mode 100644 index 02340e6a5..000000000 --- a/simplistic_calculator/typer/main_20.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - 'Hello GDSC!', - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_21.dart b/simplistic_calculator/typer/main_21.dart deleted file mode 100644 index bfaa5502a..000000000 --- a/simplistic_calculator/typer/main_21.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: const Center( - child: Text( - state.buffer, - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_22.dart b/simplistic_calculator/typer/main_22.dart deleted file mode 100644 index bcd11f443..000000000 --- a/simplistic_calculator/typer/main_22.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: Center( - child: Text( - state.buffer, - style: TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_23.dart b/simplistic_calculator/typer/main_23.dart deleted file mode 100644 index f16360538..000000000 --- a/simplistic_calculator/typer/main_23.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: Center( - child: Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_24.dart b/simplistic_calculator/typer/main_24.dart deleted file mode 100644 index fa539f1af..000000000 --- a/simplistic_calculator/typer/main_24.dart +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: Center( - child: Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_25.dart b/simplistic_calculator/typer/main_25.dart deleted file mode 100644 index 86c77c3f1..000000000 --- a/simplistic_calculator/typer/main_25.dart +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - children: [ - Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_26.dart b/simplistic_calculator/typer/main_26.dart deleted file mode 100644 index 6eb6fe206..000000000 --- a/simplistic_calculator/typer/main_26.dart +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - columnSizes: [1.fr], - rowSizes: [1.fr], - children: [ - Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_27.dart b/simplistic_calculator/typer/main_27.dart deleted file mode 100644 index 8cef3a277..000000000 --- a/simplistic_calculator/typer/main_27.dart +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_28.dart b/simplistic_calculator/typer/main_28.dart deleted file mode 100644 index 184dab6ea..000000000 --- a/simplistic_calculator/typer/main_28.dart +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: Text( - state.buffer, - style: const TextStyle(fontSize: 40), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_29.dart b/simplistic_calculator/typer/main_29.dart deleted file mode 100644 index f6cd577f7..000000000 --- a/simplistic_calculator/typer/main_29.dart +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 40), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_30.dart b/simplistic_calculator/typer/main_30.dart deleted file mode 100644 index c13a0007f..000000000 --- a/simplistic_calculator/typer/main_30.dart +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 40), - ), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_31.dart b/simplistic_calculator/typer/main_31.dart deleted file mode 100644 index 6d2facae1..000000000 --- a/simplistic_calculator/typer/main_31.dart +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 40), - ), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_32.dart b/simplistic_calculator/typer/main_32.dart deleted file mode 100644 index 07400f74d..000000000 --- a/simplistic_calculator/typer/main_32.dart +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_33.dart b/simplistic_calculator/typer/main_33.dart deleted file mode 100644 index 0a76af2ce..000000000 --- a/simplistic_calculator/typer/main_33.dart +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget {} diff --git a/simplistic_calculator/typer/main_34.dart b/simplistic_calculator/typer/main_34.dart deleted file mode 100644 index 1a4a59e3d..000000000 --- a/simplistic_calculator/typer/main_34.dart +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - // TODO: implement build - throw UnimplementedError(); - } -} diff --git a/simplistic_calculator/typer/main_35.dart b/simplistic_calculator/typer/main_35.dart deleted file mode 100644 index 8691ffc00..000000000 --- a/simplistic_calculator/typer/main_35.dart +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton(); - } -} diff --git a/simplistic_calculator/typer/main_36.dart b/simplistic_calculator/typer/main_36.dart deleted file mode 100644 index 4d25b1a13..000000000 --- a/simplistic_calculator/typer/main_36.dart +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - child: null, - ); - } -} diff --git a/simplistic_calculator/typer/main_37.dart b/simplistic_calculator/typer/main_37.dart deleted file mode 100644 index cb8a5d60c..000000000 --- a/simplistic_calculator/typer/main_37.dart +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: null, - ); - } -} diff --git a/simplistic_calculator/typer/main_38.dart b/simplistic_calculator/typer/main_38.dart deleted file mode 100644 index be7a56bcb..000000000 --- a/simplistic_calculator/typer/main_38.dart +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(), - ); - } -} diff --git a/simplistic_calculator/typer/main_39.dart b/simplistic_calculator/typer/main_39.dart deleted file mode 100644 index 6781ecb95..000000000 --- a/simplistic_calculator/typer/main_39.dart +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(), - ); - } -} diff --git a/simplistic_calculator/typer/main_40.dart b/simplistic_calculator/typer/main_40.dart deleted file mode 100644 index 81481339c..000000000 --- a/simplistic_calculator/typer/main_40.dart +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_41.dart b/simplistic_calculator/typer/main_41.dart deleted file mode 100644 index 99d26bfa5..000000000 --- a/simplistic_calculator/typer/main_41.dart +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.label, - }) : super(key: key); - - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_42.dart b/simplistic_calculator/typer/main_42.dart deleted file mode 100644 index 25345c8e6..000000000 --- a/simplistic_calculator/typer/main_42.dart +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.label, - }) : super(key: key); - - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_43.dart b/simplistic_calculator/typer/main_43.dart deleted file mode 100644 index 9657008ad..000000000 --- a/simplistic_calculator/typer/main_43.dart +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () {}, - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_44.dart b/simplistic_calculator/typer/main_44.dart deleted file mode 100644 index cb3864359..000000000 --- a/simplistic_calculator/typer/main_44.dart +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_45.dart b/simplistic_calculator/typer/main_45.dart deleted file mode 100644 index 2ba090a28..000000000 --- a/simplistic_calculator/typer/main_45.dart +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition {} - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_46.dart b/simplistic_calculator/typer/main_46.dart deleted file mode 100644 index 738e694a2..000000000 --- a/simplistic_calculator/typer/main_46.dart +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_47.dart b/simplistic_calculator/typer/main_47.dart deleted file mode 100644 index 48c063782..000000000 --- a/simplistic_calculator/typer/main_47.dart +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_48.dart b/simplistic_calculator/typer/main_48.dart deleted file mode 100644 index 7a81ccd09..000000000 --- a/simplistic_calculator/typer/main_48.dart +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = []; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_49.dart b/simplistic_calculator/typer/main_49.dart deleted file mode 100644 index 057e2efc8..000000000 --- a/simplistic_calculator/typer/main_49.dart +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_50.dart b/simplistic_calculator/typer/main_50.dart deleted file mode 100644 index 17a6d072e..000000000 --- a/simplistic_calculator/typer/main_50.dart +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_51.dart b/simplistic_calculator/typer/main_51.dart deleted file mode 100644 index 73ba9625d..000000000 --- a/simplistic_calculator/typer/main_51.dart +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_52.dart b/simplistic_calculator/typer/main_52.dart deleted file mode 100644 index 03b3b6bc0..000000000 --- a/simplistic_calculator/typer/main_52.dart +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_53.dart b/simplistic_calculator/typer/main_53.dart deleted file mode 100644 index a7e89aef2..000000000 --- a/simplistic_calculator/typer/main_53.dart +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_54.dart b/simplistic_calculator/typer/main_54.dart deleted file mode 100644 index 19986ba8a..000000000 --- a/simplistic_calculator/typer/main_54.dart +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_55.dart b/simplistic_calculator/typer/main_55.dart deleted file mode 100644 index 71615663a..000000000 --- a/simplistic_calculator/typer/main_55.dart +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_56.dart b/simplistic_calculator/typer/main_56.dart deleted file mode 100644 index b53af6855..000000000 --- a/simplistic_calculator/typer/main_56.dart +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_57.dart b/simplistic_calculator/typer/main_57.dart deleted file mode 100644 index d8cf69196..000000000 --- a/simplistic_calculator/typer/main_57.dart +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_58.dart b/simplistic_calculator/typer/main_58.dart deleted file mode 100644 index e9292f58d..000000000 --- a/simplistic_calculator/typer/main_58.dart +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_59.dart b/simplistic_calculator/typer/main_59.dart deleted file mode 100644 index 560936de4..000000000 --- a/simplistic_calculator/typer/main_59.dart +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_60.dart b/simplistic_calculator/typer/main_60.dart deleted file mode 100644 index b78278083..000000000 --- a/simplistic_calculator/typer/main_60.dart +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_61.dart b/simplistic_calculator/typer/main_61.dart deleted file mode 100644 index 8faa17d78..000000000 --- a/simplistic_calculator/typer/main_61.dart +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ); - } -} diff --git a/simplistic_calculator/typer/main_62.dart b/simplistic_calculator/typer/main_62.dart deleted file mode 100644 index 0331cec5b..000000000 --- a/simplistic_calculator/typer/main_62.dart +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox( - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_63.dart b/simplistic_calculator/typer/main_63.dart deleted file mode 100644 index b2329800f..000000000 --- a/simplistic_calculator/typer/main_63.dart +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_64.dart b/simplistic_calculator/typer/main_64.dart deleted file mode 100644 index e7ac179b8..000000000 --- a/simplistic_calculator/typer/main_64.dart +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text(label), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_65.dart b/simplistic_calculator/typer/main_65.dart deleted file mode 100644 index c016cfb6e..000000000 --- a/simplistic_calculator/typer/main_65.dart +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_66.dart b/simplistic_calculator/typer/main_66.dart deleted file mode 100644 index 7d5a850af..000000000 --- a/simplistic_calculator/typer/main_66.dart +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_67.dart b/simplistic_calculator/typer/main_67.dart deleted file mode 100644 index 51816ea8a..000000000 --- a/simplistic_calculator/typer/main_67.dart +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_68.dart b/simplistic_calculator/typer/main_68.dart deleted file mode 100644 index 32081d148..000000000 --- a/simplistic_calculator/typer/main_68.dart +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_69.dart b/simplistic_calculator/typer/main_69.dart deleted file mode 100644 index a544355d0..000000000 --- a/simplistic_calculator/typer/main_69.dart +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: OutlinedButton( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_70.dart b/simplistic_calculator/typer/main_70.dart deleted file mode 100644 index 56417fe3a..000000000 --- a/simplistic_calculator/typer/main_70.dart +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_71.dart b/simplistic_calculator/typer/main_71.dart deleted file mode 100644 index 82ee08275..000000000 --- a/simplistic_calculator/typer/main_71.dart +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_72.dart b/simplistic_calculator/typer/main_72.dart deleted file mode 100644 index efbefcd6a..000000000 --- a/simplistic_calculator/typer/main_72.dart +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_73.dart b/simplistic_calculator/typer/main_73.dart deleted file mode 100644 index 6b4ff5218..000000000 --- a/simplistic_calculator/typer/main_73.dart +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_74.dart b/simplistic_calculator/typer/main_74.dart deleted file mode 100644 index 60ef01f00..000000000 --- a/simplistic_calculator/typer/main_74.dart +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_75.dart b/simplistic_calculator/typer/main_75.dart deleted file mode 100644 index 24a8e744e..000000000 --- a/simplistic_calculator/typer/main_75.dart +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_76.dart b/simplistic_calculator/typer/main_76.dart deleted file mode 100644 index c54c641cd..000000000 --- a/simplistic_calculator/typer/main_76.dart +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_77.dart b/simplistic_calculator/typer/main_77.dart deleted file mode 100644 index 7fe7bcf43..000000000 --- a/simplistic_calculator/typer/main_77.dart +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_78.dart b/simplistic_calculator/typer/main_78.dart deleted file mode 100644 index 12282200d..000000000 --- a/simplistic_calculator/typer/main_78.dart +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_79.dart b/simplistic_calculator/typer/main_79.dart deleted file mode 100644 index 9c4c7a64f..000000000 --- a/simplistic_calculator/typer/main_79.dart +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_80.dart b/simplistic_calculator/typer/main_80.dart deleted file mode 100644 index 2b8524e24..000000000 --- a/simplistic_calculator/typer/main_80.dart +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_81.dart b/simplistic_calculator/typer/main_81.dart deleted file mode 100644 index d9f5ac0d3..000000000 --- a/simplistic_calculator/typer/main_81.dart +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display - seven eight nine - four five six - one two three - zero point equals - ''', - columnSizes: [1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_82.dart b/simplistic_calculator/typer/main_82.dart deleted file mode 100644 index b6bb21537..000000000 --- a/simplistic_calculator/typer/main_82.dart +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_83.dart b/simplistic_calculator/typer/main_83.dart deleted file mode 100644 index 8f16d34a7..000000000 --- a/simplistic_calculator/typer/main_83.dart +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_84.dart b/simplistic_calculator/typer/main_84.dart deleted file mode 100644 index 860489dbd..000000000 --- a/simplistic_calculator/typer/main_84.dart +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_85.dart b/simplistic_calculator/typer/main_85.dart deleted file mode 100644 index 16fa9bb1e..000000000 --- a/simplistic_calculator/typer/main_85.dart +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_86.dart b/simplistic_calculator/typer/main_86.dart deleted file mode 100644 index c6ea1f4b1..000000000 --- a/simplistic_calculator/typer/main_86.dart +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_87.dart b/simplistic_calculator/typer/main_87.dart deleted file mode 100644 index ab7e9a08b..000000000 --- a/simplistic_calculator/typer/main_87.dart +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_88.dart b/simplistic_calculator/typer/main_88.dart deleted file mode 100644 index 49828dfe2..000000000 --- a/simplistic_calculator/typer/main_88.dart +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() {} -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_89.dart b/simplistic_calculator/typer/main_89.dart deleted file mode 100644 index 9beed7e72..000000000 --- a/simplistic_calculator/typer/main_89.dart +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try {} catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_90.dart b/simplistic_calculator/typer/main_90.dart deleted file mode 100644 index 6863c6ce1..000000000 --- a/simplistic_calculator/typer/main_90.dart +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try { - final parser = Parser(); - final cm = ContextModel(); - final exp = parser.parse(state.buffer); - final result = exp.evaluate(EvaluationType.REAL, cm) as double; - } catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_91.dart b/simplistic_calculator/typer/main_91.dart deleted file mode 100644 index 27e6e2a31..000000000 --- a/simplistic_calculator/typer/main_91.dart +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try { - final parser = Parser(); - final cm = ContextModel(); - final exp = parser.parse(state.buffer); - final result = exp.evaluate(EvaluationType.REAL, cm) as double; - - if (result.isInfinite) { - state = state.copyWith( - error: 'Result is Infinite', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else if (result.isNaN) { - state = state.copyWith( - error: 'Result is Not a Number', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_92.dart b/simplistic_calculator/typer/main_92.dart deleted file mode 100644 index dbd6e6f49..000000000 --- a/simplistic_calculator/typer/main_92.dart +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try { - final parser = Parser(); - final cm = ContextModel(); - final exp = parser.parse(state.buffer); - final result = exp.evaluate(EvaluationType.REAL, cm) as double; - - if (result.isInfinite) { - state = state.copyWith( - error: 'Result is Infinite', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else if (result.isNaN) { - state = state.copyWith( - error: 'Result is Not a Number', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else { - final resultStr = result.ceil() == result - ? result.toInt().toString() - : result.toString(); - state = state.copyWith( - buffer: resultStr, - mode: CalculatorEngineMode.result, - ); - } - } catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) {}, - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_93.dart b/simplistic_calculator/typer/main_93.dart deleted file mode 100644 index 4790a7dbe..000000000 --- a/simplistic_calculator/typer/main_93.dart +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try { - final parser = Parser(); - final cm = ContextModel(); - final exp = parser.parse(state.buffer); - final result = exp.evaluate(EvaluationType.REAL, cm) as double; - - if (result.isInfinite) { - state = state.copyWith( - error: 'Result is Infinite', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else if (result.isNaN) { - state = state.copyWith( - error: 'Result is Not a Number', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else { - final resultStr = result.ceil() == result - ? result.toInt().toString() - : result.toString(); - state = state.copyWith( - buffer: resultStr, - mode: CalculatorEngineMode.result, - ); - } - } catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) => engine.evaluate(), - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - Key? key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/main_94.dart b/simplistic_calculator/typer/main_94.dart deleted file mode 100644 index 37998b854..000000000 --- a/simplistic_calculator/typer/main_94.dart +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright 2022 The Flutter team. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_layout_grid/flutter_layout_grid.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:math_expressions/math_expressions.dart'; -import 'package:window_size/window_size.dart'; - -void main() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { - WidgetsFlutterBinding.ensureInitialized(); - setWindowTitle('Simplistic Calculator'); - } - - runApp( - const ProviderScope( - child: CalculatorApp(), - ), - ); -} - -@immutable -class CalculatorState { - const CalculatorState({ - required this.buffer, - required this.mode, - required this.error, - }); - - final String buffer; - final CalculatorEngineMode mode; - final String error; - - CalculatorState copyWith({ - String? buffer, - CalculatorEngineMode? mode, - String? error, - }) => - CalculatorState( - buffer: buffer ?? this.buffer, - mode: mode ?? this.mode, - error: error ?? this.error, - ); -} - -enum CalculatorEngineMode { input, result } - -class CalculatorEngine extends StateNotifier { - CalculatorEngine() - : super( - const CalculatorState( - buffer: '0', - mode: CalculatorEngineMode.result, - error: '', - ), - ); - - void addToBuffer(String str) { - if (state.mode == CalculatorEngineMode.result) { - state = state.copyWith( - buffer: str, - mode: CalculatorEngineMode.input, - error: '', - ); - } else { - state = state.copyWith( - buffer: state.buffer + str, - error: '', - ); - } - } - - void evaluate() { - try { - final parser = Parser(); - final cm = ContextModel(); - final exp = parser.parse(state.buffer); - final result = exp.evaluate(EvaluationType.REAL, cm) as double; - - if (result.isInfinite) { - state = state.copyWith( - error: 'Result is Infinite', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else if (result.isNaN) { - state = state.copyWith( - error: 'Result is Not a Number', - buffer: '', - mode: CalculatorEngineMode.result, - ); - } else { - final resultStr = result.ceil() == result - ? result.toInt().toString() - : result.toString(); - state = state.copyWith( - buffer: resultStr, - mode: CalculatorEngineMode.result, - ); - } - } catch (err) { - state = state.copyWith( - error: err.toString(), - buffer: '', - mode: CalculatorEngineMode.result, - ); - } - } -} - -final calculatorStateProvider = - StateNotifierProvider( - (_) => CalculatorEngine()); - -class ButtonDefinition { - const ButtonDefinition({ - required this.areaName, - required this.label, - required this.op, - this.type = CalcButtonType.outlined, - }); - - final String areaName; - final String label; - final CalculatorEngineCallback op; - final CalcButtonType type; -} - -final buttonDefinitions = [ - ButtonDefinition( - areaName: 'seven', - op: (engine) => engine.addToBuffer('7'), - label: '7', - ), - ButtonDefinition( - areaName: 'eight', - op: (engine) => engine.addToBuffer('8'), - label: '8', - ), - ButtonDefinition( - areaName: 'nine', - op: (engine) => engine.addToBuffer('9'), - label: '9', - ), - ButtonDefinition( - areaName: 'four', - op: (engine) => engine.addToBuffer('4'), - label: '4', - ), - ButtonDefinition( - areaName: 'five', - op: (engine) => engine.addToBuffer('5'), - label: '5', - ), - ButtonDefinition( - areaName: 'six', - op: (engine) => engine.addToBuffer('6'), - label: '6', - ), - ButtonDefinition( - areaName: 'one', - op: (engine) => engine.addToBuffer('1'), - label: '1', - ), - ButtonDefinition( - areaName: 'two', - op: (engine) => engine.addToBuffer('2'), - label: '2', - ), - ButtonDefinition( - areaName: 'three', - op: (engine) => engine.addToBuffer('3'), - label: '3', - ), - ButtonDefinition( - areaName: 'zero', - op: (engine) => engine.addToBuffer('0'), - label: '0', - ), - ButtonDefinition( - areaName: 'point', - op: (engine) => engine.addToBuffer('.'), - label: '.', - ), - ButtonDefinition( - areaName: 'equals', - op: (engine) => engine.evaluate(), - label: '=', - type: CalcButtonType.elevated, - ), - ButtonDefinition( - areaName: 'plus', - op: (engine) => engine.addToBuffer('+'), - label: '+', - ), - ButtonDefinition( - areaName: 'minus', - op: (engine) => engine.addToBuffer('-'), - label: '-', - ), - ButtonDefinition( - areaName: 'multiply', - op: (engine) => engine.addToBuffer('*'), - label: '*', - ), - ButtonDefinition( - areaName: 'divide', - op: (engine) => engine.addToBuffer('/'), - label: '/', - ), -]; - -class CalculatorApp extends ConsumerWidget { - const CalculatorApp({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final state = ref.watch(calculatorStateProvider); - - return MaterialApp( - debugShowCheckedModeBanner: false, - home: Scaffold( - body: Container( - color: Colors.white, - child: LayoutGrid( - areas: ''' - display display display display - seven eight nine divide - four five six multiply - one two three minus - zero point equals plus - ''', - columnSizes: [1.fr, 1.fr, 1.fr, 1.fr], - rowSizes: [ - 1.fr, - 1.fr, - 1.fr, - 1.fr, - 1.fr, - ], - children: [ - NamedAreaGridPlacement( - areaName: 'display', - child: SizedBox.expand( - child: state.error.isEmpty - ? Text( - state.buffer, - textAlign: TextAlign.end, - style: const TextStyle(fontSize: 80), - ) - : Text( - state.error, - textAlign: TextAlign.start, - style: const TextStyle( - fontSize: 40, - color: Colors.red, - ), - maxLines: 2, - ), - ), - ), - ...buttonDefinitions.map( - (definition) => NamedAreaGridPlacement( - areaName: definition.areaName, - child: CalcButton( - label: definition.label, - op: definition.op, - type: definition.type, - ), - ), - ), - ], - ), - ), - ), - ); - } -} - -typedef CalculatorEngineCallback = void Function(CalculatorEngine engine); - -enum CalcButtonType { outlined, elevated } - -class CalcButton extends ConsumerWidget { - const CalcButton({ - super.key, - required this.op, - required this.label, - required this.type, - }) : super(key: key); - - final CalculatorEngineCallback op; - final String label; - final CalcButtonType type; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final buttonConstructor = type == CalcButtonType.elevated - ? ElevatedButton.new - : OutlinedButton.new; - - return SizedBox.expand( - child: Padding( - padding: const EdgeInsets.all(8), - child: buttonConstructor( - onPressed: () => op(ref.read(calculatorStateProvider.notifier)), - child: Text( - label, - style: const TextStyle(fontSize: 40, color: Colors.black54), - ), - ), - ), - ); - } -} diff --git a/simplistic_calculator/typer/steps.json b/simplistic_calculator/typer/steps.json deleted file mode 100644 index 9fd2c2335..000000000 --- a/simplistic_calculator/typer/steps.json +++ /dev/null @@ -1,378 +0,0 @@ -[ - { - "file":"lib/main.dart", - "content":"typer/main_01.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_02.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_03.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_04.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_05.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_06.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_07.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_08.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_09.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_10.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_11.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_12.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_13.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_14.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_15.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_16.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_17.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_18.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_19.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_20.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_21.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_22.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_23.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_24.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_25.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_26.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_27.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_28.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_29.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_30.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_31.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_32.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_33.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_34.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_35.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_36.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_37.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_38.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_39.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_40.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_41.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_42.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_43.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_44.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_45.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_46.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_47.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_48.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_49.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_50.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_51.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_52.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_53.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_54.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_55.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_56.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_57.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_58.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_59.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_60.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_61.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_62.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_63.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_64.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_65.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_66.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_67.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_68.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_69.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_70.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_71.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_72.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_73.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_74.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_75.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_76.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_77.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_78.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_79.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_80.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_81.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_82.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_83.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_84.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_85.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_86.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_87.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_88.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_89.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_90.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_91.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_92.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_93.dart" - }, - { - "file":"lib/main.dart", - "content":"typer/main_94.dart" - } -] \ No newline at end of file diff --git a/tool/flutter_ci_script_beta.sh b/tool/flutter_ci_script_beta.sh index 46fc36523..eff881504 100755 --- a/tool/flutter_ci_script_beta.sh +++ b/tool/flutter_ci_script_beta.sh @@ -8,6 +8,7 @@ source "$DIR/flutter_ci_script_shared.sh" flutter doctor -v declare -ar PROJECT_NAMES=( + "add_to_app/android_view/flutter_module_using_plugin" "add_to_app/books/flutter_module_books" "add_to_app/fullscreen/flutter_module" "add_to_app/multiple_flutters/multiple_flutters_module" @@ -20,16 +21,20 @@ declare -ar PROJECT_NAMES=( "code_sharing/shared" "desktop_photo_search/fluent_ui" "desktop_photo_search/material" - # TODO(justinmc): To be enabled when its PR hits the master channel. - # https://github.com/flutter/flutter/pull/107193 - # "experimental/context_menus" + "experimental/context_menus" "experimental/federated_plugin/federated_plugin" + "experimental/federated_plugin/federated_plugin/example" + "experimental/federated_plugin/federated_plugin_macos" + "experimental/federated_plugin/federated_plugin_platform_interface" + "experimental/federated_plugin/federated_plugin_web" + "experimental/federated_plugin/federated_plugin_windows" + # TODO(DomesticMouse): 'bottomAppBarColor' is deprecated and shouldn't be used. + # "experimental/linting_tool" + "experimental/material_3_demo" "experimental/varfont_shader_puzzle" "experimental/web_dashboard" - # TODO(DomesticMouse): Needs to be re-formatted for Flutter beta - # "experimental/linting_tool" "flutter_maps_firestore" - # TODO(domesticmouse): 'errorColor' is deprecated and shouldn't be used. + # TODO(DomesticMouse): 'errorColor' is deprecated and shouldn't be used. # "form_app" "game_template" "infinite_list" @@ -44,10 +49,12 @@ declare -ar PROJECT_NAMES=( "platform_view_swift" "provider_counter" "provider_shopper" - # TODO(DomesticMouse): https://github.com/flutter/samples/issues/1443 + "simplistic_calculator" + # TODO(DomesticMouse): A value of type 'dynamic' can't be returned from the method 'build' because it has a return type of 'Widget'. # "simplistic_editor" "testing_app" "veggieseasons" + "web/_tool" "web/samples_index" ) diff --git a/tool/flutter_ci_script_master.sh b/tool/flutter_ci_script_master.sh index b255e87cd..4e1a52aff 100755 --- a/tool/flutter_ci_script_master.sh +++ b/tool/flutter_ci_script_master.sh @@ -8,6 +8,7 @@ source "$DIR/flutter_ci_script_shared.sh" flutter doctor -v declare -ar PROJECT_NAMES=( + "add_to_app/android_view/flutter_module_using_plugin" "add_to_app/books/flutter_module_books" "add_to_app/fullscreen/flutter_module" "add_to_app/multiple_flutters/multiple_flutters_module" @@ -17,19 +18,23 @@ declare -ar PROJECT_NAMES=( "animations" "code_sharing/client" "code_sharing/server" + "code_sharing/shared" "desktop_photo_search/fluent_ui" "desktop_photo_search/material" - # TODO(DomesticMouse): Reformat code - # "experimental/context_menus" + "experimental/context_menus" "experimental/federated_plugin/federated_plugin" - # TODO(DomesticMouse): Error: Method not found: 'FallThroughError'. - # "experimental/web_dashboard" - # TODO(DomesticMouse): Needs to be re-formatted for Flutter beta + "experimental/federated_plugin/federated_plugin/example" + "experimental/federated_plugin/federated_plugin_macos" + "experimental/federated_plugin/federated_plugin_platform_interface" + "experimental/federated_plugin/federated_plugin_web" + "experimental/federated_plugin/federated_plugin_windows" + # TODO(DomesticMouse): 'bottomAppBarColor' is deprecated and shouldn't be used. # "experimental/linting_tool" "experimental/material_3_demo" "experimental/varfont_shader_puzzle" + "experimental/web_dashboard" "flutter_maps_firestore" - # TODO(domesticmouse): 'errorColor' is deprecated and shouldn't be used. + # TODO(DomesticMouse): 'errorColor' is deprecated and shouldn't be used. # "form_app" "game_template" "infinite_list" @@ -44,10 +49,12 @@ declare -ar PROJECT_NAMES=( "platform_view_swift" "provider_counter" "provider_shopper" - # TODO(DomesticMouse): https://github.com/flutter/samples/issues/1443 + "simplistic_calculator" + # TODO(DomesticMouse): A value of type 'dynamic' can't be returned from the method 'build' because it has a return type of 'Widget'. # "simplistic_editor" "testing_app" "veggieseasons" + "web/_tool" "web/samples_index" ) diff --git a/tool/flutter_ci_script_stable.sh b/tool/flutter_ci_script_stable.sh index b7082ca31..0f18f00dc 100755 --- a/tool/flutter_ci_script_stable.sh +++ b/tool/flutter_ci_script_stable.sh @@ -8,6 +8,7 @@ source "$DIR/flutter_ci_script_shared.sh" flutter doctor -v declare -ar PROJECT_NAMES=( + "add_to_app/android_view/flutter_module_using_plugin" "add_to_app/books/flutter_module_books" "add_to_app/fullscreen/flutter_module" "add_to_app/multiple_flutters/multiple_flutters_module" @@ -17,13 +18,23 @@ declare -ar PROJECT_NAMES=( "animations" "code_sharing/client" "code_sharing/server" + "code_sharing/shared" "desktop_photo_search/fluent_ui" "desktop_photo_search/material" + # TODO(DomesticMouse): enable after Flutter stable increment + # "experimental/context_menus" "experimental/federated_plugin/federated_plugin" - "experimental/web_dashboard" + "experimental/federated_plugin/federated_plugin/example" + "experimental/federated_plugin/federated_plugin_macos" + "experimental/federated_plugin/federated_plugin_platform_interface" + "experimental/federated_plugin/federated_plugin_web" + "experimental/federated_plugin/federated_plugin_windows" "experimental/linting_tool" - # TODO(DomesticMouse): include when stable increments + # TODO(DomesticMouse): enable after Flutter stable increment + # "experimental/material_3_demo" + # TODO(DomesticMouse): enable after Flutter stable increment # "experimental/varfont_shader_puzzle" + "experimental/web_dashboard" "flutter_maps_firestore" "form_app" "game_template" @@ -39,9 +50,11 @@ declare -ar PROJECT_NAMES=( "platform_view_swift" "provider_counter" "provider_shopper" + "simplistic_calculator" "simplistic_editor" "testing_app" "veggieseasons" + "web/_tool" "web/samples_index" )