Skip to content

PreferredSize child should be last widget on constructor invocations #128178

Description

@yeasin50

Is there an existing issue for this?

Steps to reproduce

While writing PreferredSize widget on VS Code, the auto-complete happen based on constructor which is currently` look like

PreferredSize(child: child, preferredSize: preferredSize),

It raises a warning(suggestion) from flutter_lints:^2.0.0

child should be last widget on constructor invocations

Also, if we press ctrl+space for suggestion, it shows

image

Expected results

I was expecting child as the last widget, which removes the lint warning and devs can depend on suggestion and doesn't need to change it manually.

PreferredSize(preferredSize: preferredSize,child: child)

Actual results

Currently It suggest like

PreferredSize(child: child, preferredSize: preferredSize)

Code sample

Code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      home: Scaffold(
        appBar: PreferredSize(
          child: Text(''), // this suggestion can move to next once we change the constructor,
          preferredSize: Size.fromHeight(80.0),
        ),
      ),
    );
  }
}

Screenshots or Video

image

2023-06-04.01-33-26_Trim.mp4

Logs

No response

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.3, on Microsoft Windows [Version 10.0.19045.2965], locale en-US)
    • Flutter version 3.10.3 on channel stable at C:\Tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f92f44110e (2 days ago), 2023-06-01 18:17:33 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)    
    • Android SDK at I:\SDK
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = I:\SDK
    • Java binary at: I:\Software Instlaion system Files\android_studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)   
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.3)
    • Visual Studio at I:\visual_studio_installation
    • Visual Studio Community 2022 version 17.3.32825.248
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.3)
    • Android Studio at I:\Software Instlaion system Files\android_studio    
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] IntelliJ IDEA Community Edition (version 2022.3)
    • IntelliJ at I:\Software Instlaion system Files\intelIj\IntelliJ IDEA Community Edition
    • Flutter plugin version 71.3.6
    • Dart plugin version 223.8214.16

[√] VS Code
    • VS Code at C:\Users\WCS\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.17.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.2965]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 113.0.5672.129
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 113.0.1774.57

[√] Network resources
    • All expected network resources are available.

• No issues found! 

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    on Jun 5, 2023
  2. added a commit that references this issue on Jun 20, 2023
    b733901
  3. github-actions commented on Jul 4, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions