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
Last active April 20, 2024 00:31
Example of conflicting horizontal gesture recognizers
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
@justinmc
justinmc / main.dart
Created March 15, 2024 19:05
How to return a value from a route dismissed by system back gesture. Will break predictive back in a root route, and maybe an antipattern overall.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@justinmc
justinmc / main.dart
Created February 23, 2024 00:58
Shows how keyboard shortcuts can interfere with text input, and how to solve that.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@justinmc
justinmc / main.dart
Created February 20, 2024 21:45
The different ways to select text in Flutter.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@justinmc
justinmc / main.dart
Created August 21, 2023 18:29
An example of async form validation.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Async Validator Example',
debugShowCheckedModeBanner: false,
@justinmc
justinmc / main.dart
Created June 30, 2023 17:44
Demonstrates undesired full width of link
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
Executing tasks: [:app:assembleDebug] in project /usr/local/google/home/jmccandless/AndroidStudioProjects/PredictiveBackMostBasic
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:dataBindingMergeDependencyArtifactsDebug FAILED
> Task :app:dataBindingMergeGenClassesDebug FAILED
> Task :app:generateDebugResValues UP-TO-DATE
@justinmc
justinmc / main.dart
Created May 15, 2023 18:43
Can't do nested Navigators and nested CanPopScopes
// 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 nested navigation in a bottom navigation bar.
import 'package:flutter/material.dart';
// There are three possible tabs.
enum _Tab {
@justinmc
justinmc / main.dart
Created April 11, 2023 20:54
Predictive back with go_router working without modifications to go_router
// 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:flutter/scheduler.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@justinmc
justinmc / main.dart
Created April 10, 2023 23:47
A simple GoRouter example to use to test predictive back. It doesn't work out of the box. Always exits the app.
// 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';
void main() => runApp(_MyApp());