1. 04 Dec, 2023 1 commit
  2. 10 Nov, 2023 1 commit
  3. 18 Oct, 2023 1 commit
    • Taha Tesser's avatar
      Fix `Slider` `onChanged` callback order & never calls `onChangeStart` on ... · 4f959b97
      Taha Tesser authored
      Fix `Slider` `onChanged` callback order & never calls `onChangeStart` on  `SliderInteraction.slideOnly` allowed interaction (#136720)
      
      fixes [Slider will call onChanged before onChangeStart when sliding.](https://github.com/flutter/flutter/issues/136707)
      
      This fixes a regression from https://github.com/flutter/flutter/pull/121483
      
      ### Code sample
      
      <details>
      <summary>expand to view the code sample</summary> 
      
      ```dart
      import 'package:flutter/material.dart';
      
      void main() => runApp(const MyApp());
      
      class MyApp extends StatelessWidget {
        const MyApp({super.key});
      
        @override
        Widget build(BuildContext context) {
          return const MaterialApp(
            debugShowCheckedModeBanner: false,
            home: Example(),
          );
        }
      }
      
      class Example extends StatefulWidget {
        const Example({super.key});
      
        @override
        State<Example> createState() => _ExampleState();
      }
      
      class _ExampleState extends State<Example> {
        double _sliderValue = 0.5;
      
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            body: Center(
              child: Slider(
                // allowedInteraction: SliderInteraction.tapAndSlide,
                // allowedInteraction: SliderInteraction.tapOnly,
                // allowedInteraction: SliderInteraction.slideOnly
                // allowedInteraction: SliderInteraction.slideThumb,
                value: _sliderValue,
                onChangeStart: (newValue) {
                  print("onChangeStart ......");
                },
                onChanged: (newValue) {
                  print("onChanged ......");
                  setState(() {
                    _sliderValue = newValue;
                  });
                },
                onChangeEnd: (newValue) {
                  print("onChangeEnd ......");
                },
              ),
            ),
          );
        }
      }
      ```
      
      </details>
      4f959b97
  4. 25 Aug, 2023 1 commit
  5. 07 Aug, 2023 1 commit
    • Mingyu's avatar
      Slider should check `mounted` before start interaction (#132010) · 06ca902d
      Mingyu authored
      This is a follow up to the following pull requests:
      - https://github.com/flutter/flutter/pull/124514
      
      I was finally able to reproduce this bug and found out why it was happening. Consider this code:
      
      ```dart
      GestureDetector(
        behavior: HitTestBehavior.translucent,
        // Note: Make sure onTap is not null to ensure events
        // are captured by `GestureDetector`
        onTap: () {},
        child: _shouldShowSlider
          ? Slider(value: _value, onChanged: _handleSlide)
          : const SizedBox.shrink().
      )
      ```
      
      Runtime exception happens when:
      
      1. User taps and holds the Slider (drag callback captured by `GestureDetector`)
      2. `_shouldShowSlider` changes to false, Slider disappears and unmounts, and unregisters `_handleSlide`. But the callback is still registered by `GestureDetector`
      3. Users moves finger as if Slider were still there
      4. Drag callback is invoked, `_SliderState.showValueIndicator` is called
      5. Exception - Slider is already disposed
      
      This pull request fixes it by adding a mounted check inside `_SliderState.showValueIndicator` to ensure the Slider is actually mounted at the time of invoking drag event callback. I've added a unit test that will fail without this change.
      
      The error stack trace is:
      
      ```
      The following assertion was thrown while handling a gesture:
      This widget has been unmounted, so the State no longer has a context (and should be considered
      defunct).
      Consider canceling any active work during "dispose" or using the "mounted" getter to determine if
      the State is still active.
      
      When the exception was thrown, this was the stack:
      #0      State.context.<anonymous closure> (package:flutter/src/widgets/framework.dart:950:9)
      #1      State.context (package:flutter/src/widgets/framework.dart:956:6)
      #2      _SliderState.showValueIndicator (package:flutter/src/material/slider.dart:968:18)
      #3      _RenderSlider._startInteraction (package:flutter/src/material/slider.dart:1487:12)
      #4      _RenderSlider._handleDragStart (package:flutter/src/material/slider.dart:1541:5)
      #5      DragGestureRecognizer._checkStart.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:531:53)
      #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
      #7      DragGestureRecognizer._checkStart (package:flutter/src/gestures/monodrag.dart:531:7)
      #8      DragGestureRecognizer._checkDrag (package:flutter/src/gestures/monodrag.dart:498:5)
      #9      DragGestureRecognizer.acceptGesture (package:flutter/src/gestures/monodrag.dart:431:7)
      #10     _CombiningGestureArenaMember.acceptGesture (package:flutter/src/gestures/team.dart:45:14)
      #11     GestureArenaManager._resolveInFavorOf (package:flutter/src/gestures/arena.dart:281:12)
      #12     GestureArenaManager._resolve (package:flutter/src/gestures/arena.dart:239:9)
      #13     GestureArenaEntry.resolve (package:flutter/src/gestures/arena.dart:53:12)
      #14     _CombiningGestureArenaMember._resolve (package:flutter/src/gestures/team.dart:85:15)
      #15     _CombiningGestureArenaEntry.resolve (package:flutter/src/gestures/team.dart:19:15)
      #16     OneSequenceGestureRecognizer.resolve (package:flutter/src/gestures/recognizer.dart:375:13)
      #17     DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:414:13)
      #18     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
      #19     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
      #20     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
      #21     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
      #22     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
      #23     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:488:19)
      #24     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:468:22)
      #25     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:439:11)
      #26     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:413:7)
      #27     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
      #28     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
      #29     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
      #30     _invoke1 (dart:ui/hooks.dart:186:13)
      #31     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:433:7)
      #32     _dispatchPointerDataPacket (dart:ui/hooks.dart:119:31)
      
      Handler: "onStart"
      Recognizer:
        HorizontalDragGestureRecognizer#a5df2
      ```
      
      *List which issues are fixed by this PR. You must list at least one issue.*
      
      Internal bug: b/273666179, b/192329942
      
      *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
      06ca902d
  6. 17 Jul, 2023 1 commit
    • LongCatIsLooong's avatar
      Replaces `textScaleFactor` with `TextScaler` (#128522) · b2e22d35
      LongCatIsLooong authored
      Deprecate `textScaleFactor` in favor of `textScaler`, in preparation for Android 14 [Non-linear font scaling to 200%](https://developer.android.com/about/versions/14/features#non-linear-font-scaling). The `TextScaler` class can be moved to `dart:ui` in the future, if we decide to use the Android platform API or AndroidX to get the scaling curve instead of hard coding the curve in the framework.
      
      I haven't put the Flutter version in the deprecation message so the analyzer checks are failing. Will do so after I finish the migration guide.
      
      **Why `TextScaler.textScaleFactor`**
      The author of a `TextScaler` subclass should provide a fallback `textScaleFactor`. By making `TextScaler` also contain the `textScaleFactor` information it also makes it easier to migrate: if a widget overrides `MediaQueryData.textScaler` in the tree, for unmigrated widgets in the subtree it would also have to override `MediaQueryData.textScaleFactor`, and that makes it difficult to remove `MediaQueryData.textScaleFactor` in the future.
      
      ## A full list of affected APIs in this PR
      
      Deprecated: The method/getter/setter/argument is annotated with a `@Deprecated()` annotation in this PR, and the caller should replace it with `textScaler` instead. Unless otherwise specified there will be a Flutter fix available to help with migration but it's still recommended to migrate case-by-case.
      **Replaced**:  The method this `textScaleFactor` argument belongs to is rarely called directly by user code and is not overridden by any of the registered custom tests, so the argument is directly replaced by `TextScaler`.
      **To Be Deprecated**:  The method/getter/setter/argument can't be deprecated in this PR because a registered customer test depends on it and a Flutter fix isn't available (or the test was run without applying flutter fixes first). This method/getter/setter/argument will be deprecated in a followup PR once the registered test is migrated.
      
      ### `Painting` Library
      
      | Affected API | State of `textScaleFactor` | Comment | 
      | --- | --- | --- |
      | `InlineSpan.build({ double textScaleFactor = 1.0 })` argument | **Replaced** | | 
      | `TextStyle.getParagraphStyle({ double TextScaleFactor = 1.0 })` argument | **Replaced** | |
      | `TextStyle.getTextStyle({ double TextScaleFactor = 1.0 })`  argument| Deprecated | Can't replace: https://github.com/superlistapp/super_editor/blob/c47fd38dca4b7f43611690913b551a1773c563d7/super_editor/lib/src/infrastructure/super_textfield/desktop/desktop_textfield.dart#L1903-L1905|
      | `TextPainter({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
      | `TextPainter.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
      | `TextPainter.computeWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |
      | `TextPainter.computeMaxIntrinsicWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |
      
      ### `Rendering` Library
      
      | Affected API | State of `textScaleFactor` | Comment | 
      | --- | --- | --- |
      | `RenderEditable({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
      | `RenderEditable.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
      | `RenderParagraph({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
      | `RenderParagraph.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
      
      ### `Widgets` Library
      
      | Affected API | State of `textScaleFactor` | Comment | 
      | --- | --- | --- |
      | `MediaQueryData({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/packages/flutter_markdown/test/text_scale_factor_test.dart#LL39C21-L39C35 |
      | `MediaQueryData.textScaleFactor` getter | Deprecated | |
      | `MediaQueryData.copyWith({ double? TextScaleFactor })` argument | Deprecated | |
      | `MediaQuery.maybeTextScaleFactorOf(BuildContext context)` static method | Deprecated | No Flutter Fix, not expressible yet  |
      | `MediaQuery.textScaleFactorOf(BuildContext context)` static method | **To Be Deprecated** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/packages/flutter_markdown/lib/src/_functions_io.dart#L68-L70, No Flutter Fix, not expressible yet |
      | `RichText({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/packages/flutter_markdown/lib/src/builder.dart#L829-L843 |
      | `RichText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away|
      | `Text({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | https://github.com/flutter/packages/blob/914d120da12fba458c020210727831c31bd71041/packages/rfw/lib/src/flutter/core_widgets.dart#L647 , No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
      | `Text.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
      | `Text.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |
      | `EditableText({ double? TextScaleFactor = 1.0 })` constructor argument | Deprecated | No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
      | `EditableText.textScaleFactor` getter | Deprecated | |
      
      ### `Material` Library
      
      | Affected API | State of `textScaleFactor` | Comment | 
      | --- | --- | --- |
      | `SelectableText({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/packages/flutter_markdown/lib/src/builder.dart#L829-L843, No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
      | `SelectableText.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
      | `SelectableText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |
      
      A lot of material widgets (`Slider`, `RangeSlider`, `TimePicker`, and different types of buttons) also change their layout based on `textScaleFactor`. These need to be handled in a case-by-case fashion and will be migrated in follow-up PRs.
      b2e22d35
  7. 22 Jun, 2023 1 commit
  8. 14 Jun, 2023 1 commit
    • cruiser-baxter's avatar
      Fixed slider value indicator not disappearing after a bit on desktop platform... · 52c4db8d
      cruiser-baxter authored
      Fixed slider value indicator not disappearing after a bit on desktop platform when slider is clicked not dragged (#128137)
      
      In slider.dart within the _startInteraction method and within the below conditional.
      
      "if (!_active && !hasFocus &&
      _state.valueIndicatorController.status == AnimationStatus.completed)"
      
      **Changed to:**
      
      "f (!_active &&
      _state.valueIndicatorController.status == AnimationStatus.completed)"
      This allows the value indicator to disappear after a bit when clicked instead of dragged on Desktop platform. 
      
      I also added a test in slider_test.dart to detect the bug if it ever returns.
      
      Fixes https://github.com/flutter/flutter/issues/123313
      52c4db8d
  9. 09 Jun, 2023 1 commit
    • Pierre-Louis's avatar
      Improve defaults generation with logging, stats, and token validation (#128244) · 66cda591
      Pierre-Louis authored
      ## Description
      
      This improves defaults generation with logging, stats, and token validation. 
      
      This PR includes these changes:
      * introduce `TokenLogger`, with a verbose mode
        * prints versions and tokens usage to the console
        * outputs `generated/used_tokens.csv`, a list of all used tokens, for use by Google
      * find token files in `data` automatically
      * hide tokens `Map`
        * tokens can be obtained using existing resolvers (e.g. `color`, `shape`), or directly through `getToken`.
        * tokens can be checked for existence with `tokenAvailable`
      * remove version from template, since the tokens are aggregated and multiple versions are possible (as is the case currently), it does not make sense to attribute a single version
      * improve documentation
      
      ## Related Issues
       - Fixes https://github.com/flutter/flutter/issues/122602
      
      ## Tests
       - Added tests for `TokenLogger`
       - Regenerated tokens, no-op except version removal
      
      ## Future work
      A future PR should replace or remove the following invalid tokens usages
      
      <img width="578" alt="image" src="https://github.com/flutter/flutter/assets/6655696/b6f9e5a7-523f-4f72-94f9-1b0bf4cc9f00">
      66cda591
  10. 24 May, 2023 1 commit
  11. 11 May, 2023 1 commit
    • Qun Cheng's avatar
      Reorder `materialStateProperty` defaults (#125905) · 4e7e4512
      Qun Cheng authored
      Fixes #122250. This PR is to make sure all the MaterialStateProperty defaults are able to correctly resolve different states. 
      * When a widget is pressed, it is also hovered, so we need to put the `MaterialState.pressed` check before `MaterialState.hovered`. 
      * When a widget is focused, the widget should still be able to be hovered, so we should check `MaterialState.hovered` before `MaterialState.focused`.
      * There are also cases like in _InputDecoratorDefaultsM3, the `MaterialState.disabled` should be checked before `MaterialState.error`.
      
       the order should be disabled, (error), pressed, hovered, focused.
      4e7e4512
  12. 01 May, 2023 1 commit
  13. 22 Mar, 2023 1 commit
  14. 14 Mar, 2023 1 commit
  15. 13 Mar, 2023 1 commit
  16. 13 Feb, 2023 1 commit
  17. 07 Feb, 2023 1 commit
  18. 25 Jan, 2023 1 commit
  19. 24 Jan, 2023 1 commit
  20. 19 Jan, 2023 1 commit
  21. 17 Jan, 2023 1 commit
  22. 03 Jan, 2023 1 commit
  23. 09 Dec, 2022 1 commit
  24. 01 Dec, 2022 1 commit
  25. 30 Nov, 2022 2 commits
  26. 28 Nov, 2022 1 commit
  27. 17 Nov, 2022 1 commit
  28. 15 Nov, 2022 1 commit
  29. 02 Nov, 2022 1 commit
  30. 25 Oct, 2022 1 commit
  31. 06 Oct, 2022 1 commit
  32. 06 Sep, 2022 1 commit
  33. 02 Sep, 2022 1 commit
  34. 28 Aug, 2022 1 commit
  35. 22 Aug, 2022 1 commit
  36. 02 Aug, 2022 1 commit
  37. 28 Jul, 2022 1 commit
  38. 25 May, 2022 2 commits