Skip to content

Instantly share code, notes, and snippets.

View justinmc's full-sized avatar

Justin McCandless justinmc

View GitHub Profile
@justinmc
justinmc / main.dart
Created April 10, 2023 23:32
Nested GoRouters with predictive back
// Copyright 2014 The Flutter Authors. 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:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(_MyApp());
@justinmc
justinmc / main.dart
Created April 10, 2023 22:30
A vanilla example of nested GoRouters, without the use of WillPopScope.
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a vanilla example of nested GoRouters.
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
@justinmc
justinmc / main.dart
Created April 7, 2023 22:23
This gist illustrates that a WillPopScope widget inside of a nested Navigator widget has no effect.
import 'package:flutter/material.dart';
void main() => runApp(_MyApp());
class _MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/nested_navigator',
routes: <String, WidgetBuilder>{
@justinmc
justinmc / main.dart
Last active April 7, 2023 18:50
Futile attempts at listening to all types of route changes of a Navigator.
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This sample demonstrates using CanPopScope to get the correct behavior from
// system back gestures when there are nested Navigator widgets.
import 'package:flutter/material.dart';
final RouteObserver<ModalRoute<void>> routeObserver = RouteObserver<ModalRoute<void>>();
@justinmc
justinmc / main.dart
Created March 30, 2023 16:14
Shows the height of a TextField with maxLines
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@justinmc
justinmc / lsp.log
Created March 9, 2023 00:17
nvim-lspconfig bug report log file
[START][2022-12-16 13:13:28] LSP logging initiated
[START][2022-12-16 13:22:50] LSP logging initiated
[START][2022-12-16 13:26:15] LSP logging initiated
[START][2022-12-20 10:51:50] LSP logging initiated
[START][2022-12-20 10:53:47] LSP logging initiated
[START][2022-12-20 10:57:09] LSP logging initiated
[START][2022-12-20 10:58:52] LSP logging initiated
[START][2022-12-20 10:59:12] LSP logging initiated
[START][2023-03-08 15:42:52] LSP logging initiated
[ERROR][2023-03-08 15:42:52] .../vim/lsp/rpc.lua:420 "rpc" "/usr/local/google/home/jmccandless/Projects/flutter/bin/dart" "stderr" "Building flutter tool...\n"
@justinmc
justinmc / main.dart
Created December 6, 2022 18:59
Flutter Forward 2023: An example of adapting to window size using MediaQuery.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@justinmc
justinmc / main.dart
Created December 6, 2022 18:00
Flutter Forward 2023: Example of adding a custom button to a TextField's context menu on all platforms.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@justinmc
justinmc / main.dart
Created December 5, 2022 23:39
Flutter Forward 2023: Example of handling light mode and dark mode in Material.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@justinmc
justinmc / main.dart
Created December 5, 2022 23:34
Flutter Forward 2023: Example of handling light mode and dark mode in Cupertino.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart' show Icons;
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});