1. 17 Aug, 2023 1 commit
  2. 08 Aug, 2023 1 commit
  3. 04 Aug, 2023 1 commit
    • Justin McCandless's avatar
      Predictive back support for root routes (#120385) · dedd100e
      Justin McCandless authored
      This PR aims to support Android's predictive back gesture when popping the entire Flutter app.  Predictive route transitions between routes inside of a Flutter app will come later.
      
      <img width="200" src="https://user-images.githubusercontent.com/389558/217918109-945febaa-9086-41cc-a476-1a189c7831d8.gif" />
      
      ### Trying it out
      
      If you want to try this feature yourself, here are the necessary steps:
      
        1. Run Android 33 or above.
        1. Enable the feature flag for predictive back on the device under "Developer
           options".
        1. Create a Flutter project, or clone [my example project](https://github.com/justinmc/flutter_predictive_back_examples).
        1. Set `android:enableOnBackInvokedCallback="true"` in
           android/app/src/main/AndroidManifest.xml (already done in the example project).
        1. Check out this branch.
        1. Run the app. Perform a back gesture (swipe from the left side of the
           screen).
      
      You should see the predictive back animation like in the animation above and be able to commit or cancel it.
      
      ### go_router support
      
      go_router works with predictive back out of the box because it uses a Navigator internally that dispatches NavigationNotifications!
      
      ~~go_router can be supported by adding a listener to the router and updating SystemNavigator.setFrameworkHandlesBack.~~
      
      Similar to with nested Navigators, nested go_routers is supported by using a PopScope widget.
      
      <details>
      
      <summary>Full example of nested go_routers</summary>
      
      ```dart
      // 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());
      
      class _MyApp extends StatelessWidget {
        final GoRouter router = GoRouter(
          routes: <RouteBase>[
            GoRoute(
              path: '/',
              builder: (BuildContext context, GoRouterState state) => _HomePage(),
            ),
            GoRoute(
              path: '/nested_navigators',
              builder: (BuildContext context, GoRouterState state) => _NestedGoRoutersPage(),
            ),
          ],
        );
      
        @override
        Widget build(BuildContext context) {
          return MaterialApp.router(
            routerConfig: router,
          );
        }
      }
      
      class _HomePage extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(
              title: const Text('Nested Navigators Example'),
            ),
            body: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  const Text('Home Page'),
                  const Text('A system back gesture here will exit the app.'),
                  const SizedBox(height: 20.0),
                  ListTile(
                    title: const Text('Nested go_router route'),
                    subtitle: const Text('This route has another go_router in addition to the one used with MaterialApp above.'),
                    onTap: () {
                      context.push('/nested_navigators');
                    },
                  ),
                ],
              ),
            ),
          );
        }
      }
      
      class _NestedGoRoutersPage extends StatefulWidget {
        @override
        State<_NestedGoRoutersPage> createState() => _NestedGoRoutersPageState();
      }
      
      class _NestedGoRoutersPageState extends State<_NestedGoRoutersPage> {
        late final GoRouter _router;
        final GlobalKey<NavigatorState> _nestedNavigatorKey = GlobalKey<NavigatorState>();
      
        // If the nested navigator has routes that can be popped, then we want to
        // block the root navigator from handling the pop so that the nested navigator
        // can handle it instead.
        bool get _popEnabled {
          // canPop will throw an error if called before build. Is this the best way
          // to avoid that?
          return _nestedNavigatorKey.currentState == null ? true : !_router.canPop();
        }
      
        void _onRouterChanged() {
          // Here the _router reports the location correctly, but canPop is still out
          // of date.  Hence the post frame callback.
          SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
            setState(() {});
          });
        }
      
        @override
        void initState() {
          super.initState();
      
          final BuildContext rootContext = context;
          _router = GoRouter(
            navigatorKey: _nestedNavigatorKey,
            routes: [
              GoRoute(
                path: '/',
                builder: (BuildContext context, GoRouterState state) => _LinksPage(
                  title: 'Nested once - home route',
                  backgroundColor: Colors.indigo,
                  onBack: () {
                    rootContext.pop();
                  },
                  buttons: <Widget>[
                    TextButton(
                      onPressed: () {
                        context.push('/two');
                      },
                      child: const Text('Go to another route in this nested Navigator'),
                    ),
                  ],
                ),
              ),
              GoRoute(
                path: '/two',
                builder: (BuildContext context, GoRouterState state) => _LinksPage(
                  backgroundColor: Colors.indigo.withBlue(255),
                  title: 'Nested once - page two',
                ),
              ),
            ],
          );
      
          _router.addListener(_onRouterChanged);
        }
      
        @override
        void dispose() {
          _router.removeListener(_onRouterChanged);
          super.dispose();
        }
      
        @override
        Widget build(BuildContext context) {
          return PopScope(
            popEnabled: _popEnabled,
            onPopped: (bool success) {
              if (success) {
                return;
              }
              _router.pop();
            },
            child: Router<Object>.withConfig(
              restorationScopeId: 'router-2',
              config: _router,
            ),
          );
        }
      }
      
      class _LinksPage extends StatelessWidget {
        const _LinksPage ({
          required this.backgroundColor,
          this.buttons = const <Widget>[],
          this.onBack,
          required this.title,
        });
      
        final Color backgroundColor;
        final List<Widget> buttons;
        final VoidCallback? onBack;
        final String title;
      
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            backgroundColor: backgroundColor,
            body: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(title),
                  //const Text('A system back here will go back to Nested Navigators Page One'),
                  ...buttons,
                  TextButton(
                    onPressed: onBack ?? () {
                      context.pop();
                    },
                    child: const Text('Go back'),
                  ),
                ],
              ),
            ),
          );
        }
      }
      ```
      
      </details>
      
      ### Resources
      
      Fixes https://github.com/flutter/flutter/issues/109513
      Depends on engine PR https://github.com/flutter/engine/pull/39208 :heavy_check_mark: 
      Design doc: https://docs.google.com/document/d/1BGCWy1_LRrXEB6qeqTAKlk-U2CZlKJ5xI97g45U7azk/edit#
      Migration guide: https://github.com/flutter/website/pull/8952
      dedd100e
  4. 27 Jul, 2023 1 commit
  5. 25 Jul, 2023 2 commits
    • Loïc Sharma's avatar
      Revert "Proposal to add barrier configs for showDatePicker, showTimePicker and... · 300c5d82
      Loïc Sharma authored
      Revert "Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog." (#131278)
      
      Reverts flutter/flutter#130484. /cc @ronnnnn
      
      Example failure: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20framework_tests_libraries/12185/overview
      
      <details>
      <summary>Failure logs...</summary>
      
      ```
      04:51 +5379 ~18: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter                                    
      ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
      The following TestFailure was thrown running a test:
      Expected: <1>
        Actual: <2>
      
      When the exception was thrown, this was the stack:
      #4      main.<anonymous closure>.<anonymous closure> (file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart:776:7)
      <asynchronous suspension>
      #5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:165:15)
      <asynchronous suspension>
      #6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1008:5)
      <asynchronous suspension>
      <asynchronous suspension>
      (elided one frame from package:stack_trace)
      
      This was caught by the test expectation on the following line:
        file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart line 776
      The test description was:
        Barrier is dismissible with default parameter
      ════════════════════════════════════════════════════════════════════════════════════════════════════
      
      04:51 +5379 ~18 -1: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter [E]                             
        Test failed. See exception logs above.
        The test description was: Barrier is dismissible with default parameter
        
      To run this test again: /Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/dart test /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart -p vm --plain-name 'Barrier dismissible Barrier is dismissible with default parameter'
      ```
      
      </details>
      300c5d82
    • Seiya Kokushi's avatar
      Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog. (#130484) · 9def8f6b
      Seiya Kokushi authored
      ### Overview
      
      Add `barrierDismissible`, `barrierColor` and `barrierLabel` parameters to  `showDatePicker`, `showTimePicker` and `showAboutDialog` which calls `showDialog` internally.
      We can change these parameters with `showDialog` and Dialog widgets (like `DatePickerDialog`, `TimePickerDialog` or `AboutDialog`) directly. But, I think it is prefer to provide interfaces same as `showDialog` to keep application wide unified looks if it is used internally.
      
      Fixes #130971
      9def8f6b
  6. 17 May, 2023 1 commit
  7. 06 Mar, 2023 1 commit
  8. 21 Feb, 2023 1 commit
    • Jessica Pereira's avatar
      Fix license page rtl (#120497) · aa29358c
      Jessica Pereira authored
      * fix license page rtl
      
      * fix editor spacings, tests to lateral view
      
      * fix defaultSize and setSurfaceSize
      
      * add validation for packageList position
      
      * fix spacing
      
      * simplify align
      aa29358c
  9. 15 Feb, 2023 1 commit
  10. 31 Jan, 2023 1 commit
  11. 24 Jan, 2023 1 commit
  12. 04 Jan, 2023 1 commit
  13. 11 Dec, 2022 1 commit
  14. 09 Dec, 2022 1 commit
  15. 15 Nov, 2022 1 commit
  16. 31 Oct, 2022 1 commit
  17. 22 Aug, 2022 1 commit
  18. 19 Aug, 2022 1 commit
  19. 10 Aug, 2022 1 commit
  20. 18 Jul, 2022 1 commit
  21. 25 May, 2022 1 commit
  22. 09 May, 2022 1 commit
  23. 14 Apr, 2022 1 commit
  24. 30 Mar, 2022 1 commit
  25. 08 Mar, 2022 1 commit
  26. 01 Mar, 2022 1 commit
  27. 03 Feb, 2022 1 commit
  28. 14 Jan, 2022 1 commit
  29. 13 Jan, 2022 1 commit
  30. 14 Oct, 2021 2 commits
  31. 12 Oct, 2021 1 commit
  32. 11 Oct, 2021 1 commit
  33. 08 Oct, 2021 3 commits
  34. 04 Oct, 2021 1 commit
    • Greg Spencer's avatar
      Clean up examples, remove section markers and --template args (#91133) · fd9ce277
      Greg Spencer authored
      This does a cleanup of the examples, removing all of the "section" markers and extra comments that we don't need anymore now that the samples are no longer in the source code. It also removes the --template arguments from the {@tool dartpad} and {@tool sample} directives, since those are no longer used. It converts two examples that I discovered were still embedded into linked examples in the examples folder.
      
      I didn't delete the templates from the snippets config folder yet, because there are still embedded samples in the dart:ui package from the engine that use them. Once dart:ui no longer uses the templates, they can be removed.
      
      I bumped the version of the snippets package to pick up a change that allows removal of the --template argument.
      fd9ce277
  35. 25 Aug, 2021 1 commit
    • Greg Spencer's avatar
      Extract Sample code into examples/api (#87280) · 33403bd2
      Greg Spencer authored
      This extracts the sample code out from the API doc comments, and places them in separate files on disk, allowing running of the examples locally, testing them, and building of slightly larger examples.
      33403bd2
  36. 15 Jul, 2021 1 commit