Git Product home page Git Product logo

flash-chat-flutter-refactor-challenge's Introduction

Flash Chat Refactoring Challenge

Part 1:

The welcome screen, the login screen and the registration screen all have the same style of button. The code for this button should ideally be in a separate class in its own file.

  • Locate the Padding widget that contains the MaterialButton in the welcome_screen.dart. Make a note of the colours of the buttons. You'll need these colours later.

  • Extract the entire Padding widget into a separate StatelessWidget called RoundedButton.

  • Add three properties to the RoundedButton: a Color variable, a String variable for button title, and a Function variable for the button's onPressed callback. Modify the RoundedButton's constructor so that these properties are assigned a value when a RoundedButton is created.

  • Modify the code in the RoundedButton to replace the hard-coded title, colour, and onPressed callback to use the three properties you created above.

  • Create a new directory under lib called components. Inside components create a new file called rounded_button.dart.

  • Add the code for the RoundedButton class to the new file.

  • Refactor the code in the welcome_screen.dart, the login_screen.dart, and the registration_screen.dart to use the RoundedButton. Hint: Leave the code inside the callback for the button's onPressed on the login and registration screen blank (for now).

Part 2:

The TextField for entering the email (and password) is heavily styled by the decoration property. Let's extract the code for the InputDecoration and add it to the constants.dart file instead. There the decoration can sit alongside its friends which will also further simplify our registration_screen.dart and login_screen.dart.

  • In the constants.dart create a new const called kTextFieldDecoration. Set this constant equal to the InputDecoration used to style the email and password fields.

  • Make use of the kTextFieldDecoration on the registration_screen.dart and login_screen.dart.

Hint: Vary the hintText using .copyWith().

flash-chat-flutter-refactor-challenge's People

Contributors

themuellenator avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.