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
width = context.widthPx
breakpoint = AppBreakpoint.fromWidth(width)
margin = AppBreakpoint.margin
body = AppBreakpoint.body
padding = AppBreakpoint.padding
spacer = AppBreakpoint.spacer
visualDensity = AppBreakpoint.visDensity
// 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';
import 'package:layout_helpers/src/layout_helpers/app_breakpoint.dart';
import 'package:layout_helpers/src/layout_helpers/window_size_breakpoint.dart';
// 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';
import 'package:layout_helpers/src/layout_helpers/breakpoint_screen_size_ext.dart';
import 'package:layout_helpers/src/layout_helpers/window_size_breakpoint.dart';
/// Class to assist ext methods in passing
@fredgrott
fredgrott / breakpoint_screen_size_ext.dart
Created May 30, 2024 18:44
breakpoint screen size ext
// 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';
import 'package:layout_helpers/src/layout_helpers/window_size_breakpoint.dart';
extension BreakpointScreenSizeExt on WindowSizeBreakpoint {
static WindowSizeBreakpoint screenSize(double width) {
@fredgrott
fredgrott / window_size_breakpoint.dart
Created May 30, 2024 18:40
window size breakpoint
// 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.
/// WindowSizeBreakpoint according to MD3, see:
/// https://m3.material.io/foundations/layout/applying-layout/window-size-classes
///
/// Just an easy way to use enumerated types in enums to
@fredgrott
fredgrott / sized_context_ext.dart
Created May 30, 2024 18:32
sized context ext
// 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 'dart:math';
import 'package:flutter/material.dart';
import 'package:universal_platform/universal_platform.dart';
@fredgrott
fredgrott / app.dart
Created May 18, 2024 18:28
app di example
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:state_part_get_it/service_locator.dart';
import 'package:state_part_get_it/src/custom_scroll_behavior.dart';
import 'package:state_part_get_it/src/global_context.dart';
import 'package:state_part_get_it/src/layout_utils.dart';
import 'sample_feature/sample_item_details_view.dart';
import 'sample_feature/sample_item_list_view.dart';
@fredgrott
fredgrott / settings_view.dart
Created May 18, 2024 18:27
settings view with di
import 'package:flutter/material.dart';
import 'package:state_part_get_it/service_locator.dart';
import 'settings_controller.dart';
/// Displays the various settings that can be customized by the user.
///
/// When a user changes a setting, the SettingsController is updated and
/// Widgets that listen to the SettingsController are rebuilt.
class SettingsView extends StatelessWidget {
@fredgrott
fredgrott / service_locator.dart
Created May 18, 2024 18:25
get it di example
// ambient variable to access the service locator
import 'package:get_it/get_it.dart';
import 'package:state_part_get_it/src/settings/settings_controller.dart';
import 'package:state_part_get_it/src/settings/settings_service.dart';
GetIt sl = GetIt.instance;
void setUp() {
// In General register the dependent serivce
// before the other entity using it.
@fredgrott
fredgrott / pane_container_widget.dart
Created May 5, 2024 17:13
pane container widget
// 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_extras/src/layout_utils.dart';
import 'package:adaptive_extras/src/new_surface_theme.dart';
import 'package:adaptive_extras/src/surface_color_enum.dart';
import 'package:adaptive_extras/src/text_direction.dart';
import 'package:flutter/material.dart';