question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extract Widget: Update Constructor for Widget

See original GitHub issue

Hey hey – Another bit of feedback regarding extract widget! Thanks so much for your help and providing the functionality, really cool to use it 😃

I’d love it if the new “Extract Widget” function created a constructor that follows the normal conventions for Widget constructors:

“By convention, widget constructors only use named arguments. Named arguments can be marked as required using @required. Also by convention, the first argument is key, and the last argument is child, children, or the equivalent.”

From https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html

Steps to Reproduce

  1. Select Widget
  2. Extract Widget
  3. See this constructor used: NewWidget(this.todo, this.taskKey, this.isEditing, this.noteKey);
  4. Would prefer to see this constructor used: NewWidget({Key key, this.todo, this.taskKey, this.isEditing, this.noteKey}) : super(key: key);

No need to add the @required fields, as that’s more of a judgement call than an automatic refactoring.

Version info

[✓] Flutter (Channel beta, v0.3.1, on Mac OS X 10.13.4 17E199, locale en-US)
    • Flutter version 0.3.1 at /Users/phillywiggins/lab/flutter
    • Framework revision 12bbaba9ae (7 days ago), 2018-04-19 23:36:15 -0700
    • Engine revision 09d05a3891
    • Dart version 2.0.0-dev.48.0.flutter-fe606f890b

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/phillywiggins/Library/Android/sdk
    • Android NDK at /Users/phillywiggins/Library/Android/sdk/ndk-bundle
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME = /Users/phillywiggins/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.3, Build version 9E145
    • ios-deploy 1.9.2
    • CocoaPods version 1.3.1

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 23.2.2
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Community Edition (version 2018.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 24.0.2
    • Dart plugin version 181.4668.60

[✓] VS Code (version 1.22.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Dart Code extension version 2.11.2

[✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

• No issues found!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pqcommented, Jun 2, 2018

/cc @DanTup

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter - How to Extract Widget with onPressed setState inside?
I want to Extract a Widget with onPressed setState inside but I get the Message "Reference to an enclosing class method cannot be...
Read more >
Flutter Tutorial for Beginners #20 - Extracting Widgets - YouTube
Hey gang, in this Flutter tutorial I'll show you how you can extract widget trees into their own re-usable class widget.
Read more >
Simple ways to pass to and share data with widgets/pages
The simplest way to send data from a widget to another is by its constructor. Let's say, for example, we need to pass...
Read more >
How and when to force a Flutter widget rebuild - LogRocket Blog
Sometimes, a Flutter widget requires manual rebuilding in order to update. Learn why this is the case (and how to implement it) here....
Read more >
StatefulWidget class - widgets library - Flutter - Dart API docs
To do this, simply assign a widget to a final state variable and re-use it in the build method. It is massively more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found