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 / sample.dart
Created April 10, 2024 19:16
json examples
// decode
final json = json.decode(...);
final archive = KeyedArchive.unarchive(json);
final person = Person()..decode(archive);
//encode
final person = Person()..name = "Bob";
final archive = KeyedArchive.archive(person);
final json = json.encode(archive);
@fredgrott
fredgrott / data.dart
Created April 10, 2024 19:12
data class using json helper
class Person extends Coding {
String name;
@override
void decode(KeyedArchive object) {
// must call super
super.decode(object);
name = object.decode("name");
}
@fredgrott
fredgrott / resolver.dart
Created April 10, 2024 19:07
resolver json
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'package:json_helpers/json_helpers/keyed_archive.dart';
class ReferenceResolver {
@fredgrott
fredgrott / list.dart
Created April 10, 2024 19:05
list json
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'dart:collection';
import 'package:json_helpers/json_helpers/codable.dart';
@fredgrott
fredgrott / codable.dart
Created April 10, 2024 19:03
codable json
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'package:json_helpers/json_helpers/resolver.dart';
abstract class Referencable {
@fredgrott
fredgrott / cast.dart
Created April 10, 2024 19:01
cast json
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'dart:async' as async;
import 'dart:core' as core;
import 'dart:core' hide Map, String, int;
@fredgrott
fredgrott / keyed_archive.dart
Created April 10, 2024 18:57
keyed archive json
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'dart:collection';
import 'package:json_helpers/json_helpers/cast.dart' as cast;
@fredgrott
fredgrott / coding.dart
Created April 10, 2024 18:50
json base class
// Copyright 2024 Fredrick Allan Hrott. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Modified from original by codable BSD 2 clause
// license 2019.
import 'package:flutter/foundation.dart';
import 'package:json_helpers/json_helpers/cast.dart' as cast;
import 'package:json_helpers/json_helpers/keyed_archive.dart';
@fredgrott
fredgrott / darkmode.dart
Created March 26, 2024 16:43 — forked from maheshmnj/darkmode.dart
Sample code showing dark mode transition similar to Telegram in flutter with circular transition. Blog Post: https://maheshmnj.medium.com/leveraging-clippaths-in-flutter-a5f34c795ae5
class DarkTransition extends StatefulWidget {
const DarkTransition(
{required this.childBuilder,
Key? key,
this.offset = Offset.zero,
this.themeController,
this.radius,
this.duration = const Duration(milliseconds: 400),
this.isDark = false})
: super(key: key);
@fredgrott
fredgrott / settings_view.dart
Created March 22, 2024 19:58
settings view
// ignore_for_file: cast_nullable_to_non_nullable
import 'package:easy_hive/easy_hive.dart';
import 'package:flutter/material.dart';
import 'package:theme_change_anim/src/domain/general_settings_extension.dart';
import 'package:theme_change_anim/src/domain/settings_box_service.dart';
import 'package:theme_change_anim/src/domain/settings_model.dart';
class SettingsView extends StatefulWidget {
const SettingsView({super.key});