Skip to content

Instantly share code, notes, and snippets.

View fredgrott's full-sized avatar
👾
focusing on flutter cross platform mobile dev

Fred Grott fredgrott

👾
focusing on flutter cross platform mobile dev
View GitHub Profile
@fredgrott
fredgrott / app_lifecycle_mixin.dart
Created April 17, 2025 19:20
app lifecycle mixin
// Copyright 2025 Fredrick Allan Grott. 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';
import 'package:lifecycle/lifecycle.dart';
import 'package:userinterface/core/lifecycle/app_lifecycle_globals.dart';
/// Subscribes lifecycle events for normal widgets.
/// This is used to wrap the scaffold of the app so that
@fredgrott
fredgrott / app_lifecycle_globals.dart
Created April 17, 2025 19:19
app lifecycle globals
// Copyright 2025 Fredrick Allan Grott. 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:ui';
/// Used with the AppLifecycleMixin scaffold wrapper
/// and in MediaQuery extensions I use this to get the devicePixelRatio
/// and size as the size will represent the physical size in foldables and
/// big screens where multiple windows may exist.
@fredgrott
fredgrott / students.dart
Created April 7, 2025 17:36
students value class
import 'package:fast_immutable_collections/fast_immutab le_collections.dart';
class Students with FromISetMixin<Student, Students> {
final ISet<Student> _students;
Students([Iterable<Student> students]) : _students = ISet(students);
Students newInstance(ISet<Student> iset) => Students(iset);
ISet<Student> get iter => _students;
@fredgrott
fredgrott / student.dart
Created April 7, 2025 14:22
student value class example
class Student implements Comparable<Student> {
final String name;
const Student(this.name);
String toString() => "Student: $name";
bool operator ==(Object other) =>
identical(this, other) ||
other is Student &&
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
class Employees with FromIListMixin<Person. Employees> {
final Ilist<Person> _employees;
Employees([Iterable<Person> employees]) : _employees = IList(employees);
Employees newInstance(IList<Person> iList) => Employees(iList);
@fredgrott
fredgrott / person.dart
Created April 7, 2025 00:20
person value class example
class Person implements Comparable<Person>{
final String name;
Person(this.name);
String toString() => name;
bool operator ==(Object other) => identical(this, other) || other is Person;
int get hashCode => name.hasCode;
@fredgrott
fredgrott / snippet.dart
Created March 20, 2025 21:17
tyoical calls to data fixtures
PersonFixture.factory.makeSingle();
PersonFixture.factory().empty("George").make();
PersonJSONFixture.factory().makeJsonObject();
PersonJSONFixture.factory().empty("George").makeJsonObject();
@fredgrott
fredgrott / data_fixtures_person_model.dart
Created March 20, 2025 17:26
data fixtures for the person model
import 'package:data_fixture_dart/data_fixture_dart.dart';
import 'person.dart';
extension PersonFixture on Person {
static _PersonFixtureFactory factory() => _PersonFixtureFactory();
}
class _PersonFixtureFactory extends FixtureFactory<person>{
@override
FixtureDefinition<Person> defintion() => define(
@fredgrott
fredgrott / person.dart
Created March 20, 2025 17:18
person model
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
import 'package:uuid/uuid.dart';
import 'data_id_mixin.dart';
part 'person.g.dart';
@immutable
@JsonSerializable()
class Person with DataIdMixin, EquatableMixin {
@fredgrott
fredgrott / data_id_mixin.dart
Created March 20, 2025 17:14
data id mixin
mixin DataIdMixin {
late String id;
}