Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Christian Findlay MelbourneDeveloper

🏠
Working from home
View GitHub Profile
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active Jan 30, 2023
ValueNotifier Sample Inspired By flutter_bloc Library Example
View main.dart
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
void observe(
String change,
String state,
) =>
View table.md
Confidence Maintainability Execution Time Isolation
Single Function Unit Test Depends Lowest Fastest Full
Full App Composition With Mocks High Medium Medium Little
Full End To End Test Full Highest Slowest None
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created Jan 26, 2023
Integration Vs. Unit Tests
View main.dart
import 'package:test/test.dart';
typedef NumberFunction = int Function(int);
int addTwo(int original) => original + 2;
int multiplyByTwo(int original) => original * 2;
int subtractThree(int original) => original - 3;
int calculate(
int original,
NumberFunction addTwo,
View main.dart
import 'package:flutter/material.dart';
class Counter extends ValueNotifier<int> {
Counter(int value) : super(value);
void increment() => value++;
}
void main() {
runApp(const MyApp());
View main.cshtml
@page "/counter"
<h1>Counter</h1>
<p›Current count: A@currentCount‹/p>
‹button class="bt btn-primary" @onclick="IncrementCount"›Click me‹/button>
@code {
private int currentCount = 0;
private void IncrementCount ()
{
currentCount++;
}
@MelbourneDeveloper
MelbourneDeveloper / transcript.md
Last active Jan 9, 2023
ChatGPT User Registration Conversation
View transcript.md

Christian Findlay

write me a user registration screen in flutter. give me an example of the usage so I can see it in action

ChatGPT

Here is an example of a user registration screen in Flutter:

import 'package:flutter/material.dart';
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created Jan 9, 2023
Regsistration Screen Built By ChatGPT
View main.dart
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created Jan 9, 2023
Immutable State and StatelessWidgets Without Library
View main.dart
import 'package:flutter/material.dart';
@immutable
class Counter {
const Counter(this.count);
final int count;
Counter copyWith({int? count}) => Counter(count ?? this.count);
}
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active Jan 9, 2023
ioc_container Riverpod Example Style
View main.dart
/* This example is based on the flutter_riverpod sample here:
https://pub.dev/packages/flutter_riverpod/example
but doesn't use any of the Riverpod code
It demonstrates how you can use ioc_container in a similar way to Riverpod
Grab ioc_container here: https://pub.dev/packages/ioc_container
*/
import 'package:flutter/material.dart';
View test.dart
import 'package:test/test.dart';
enum Operation { add, subtract, multiply, divide }
int calculate(Operation operation, int a, int b) {
switch (operation) {
case Operation.add:
return a + b;
case Operation.subtract:
return a - b;