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 / snippet.dart
Created May 3, 2024 18:23
media query wrapper scaffold
MediaQuery.withClapedTextScaling(
maxScaleFactor: MediaQuery.texdtScalerOf(context),
child: ScaffoldWidget(),
)
@fredgrott
fredgrott / layoututils.dart
Created May 3, 2024 18:19
layout utilies
// Copyright 2024 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:adaptive_constraints/src/breakpoints.dart';
import 'package:flutter/material.dart';
/// LayoutUtils to assist in implementing Canonical page layouts
/// to serves as content for an adaptive scaffold.
///
// Copyright 2024 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';
// Note: Generally when we implement models required in
// implementing the adaptive scaffold and canonical
// layout patterns we do not stick models or entities
// in the domain layer but keep them together with
@fredgrott
fredgrott / breakpoints_main_getter.dart
Created May 3, 2024 18:08
breakpoints main getter
static WindowSizeEnum getWindowSize(BuildContext context) {
if (isCompact(context)) {
return WindowSizeEnum.compact;
} else if (isMedium(context)) {
return WindowSizeEnum.medium;
} else if (isExpanded(context)) {
return WindowSizeEnum.expanded;
} else if (isLarge(context)) {
return WindowSizeEnum.large;
} else if (isExtra(context)) {
@fredgrott
fredgrott / breakpoints_getters_snippet.dart
Created May 3, 2024 18:05
breakpoints getters snippet
/// Determines if the screen is in the compact window size.
///
/// Returns `true` if the screen width is less than 600 pixels, `false` otherwise.
static bool isCompact(BuildContext context) {
return MediaQuery.of(context).size.width < WindowSizeEnum.medium.begin ? true : false;
}
/// Determines if the screen is in the medium window size.
///
/// Returns `true` if the screen width is less than 840 pixels, `false` otherwise.
@fredgrott
fredgrott / window_size_enum_snippet.dart
Created May 3, 2024 18:02
window size enum snippet
/// Model for Adaptive Scaffold implementations accoding
/// to Dart enumerated types. See Canonical Layouts for
/// Window Size class numbers at:
/// https://m3.material.io/foundations/layout/canonical-layouts/list-detail
///
/// @author Fredrick Allan Grott
enum WindowSizeEnum {
/// The compact window size
compact(0, 599),
package com.microsoft.device.dualscreen.twopanelayout
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
@fredgrott
fredgrott / BasicDestination.kt
Created May 3, 2024 17:33
android native adaptive scaffold parts
package com.microsoft.device.dualscreen.twopanelayout
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
Implementation:
implementation("androidx.navigation:navigation-compose:2.7.2")
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
MainActivity.kt:
import android.annotation.SuppressLint
import androidx.compose.material3.ExperimentalMaterial3Api
import android.os.Bundle
@fredgrott
fredgrott / localization_test.dart
Created April 22, 2024 14:47
testing localizations
// 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.
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
// General idea is the localizations in the model are referred to as