How to extend the Focus Class?

Flutter and FlutterFlow can make you feel as though you have never touched a computer before in your life.

#1. Flutter left the focus issue unfinished... Therefore FlutterFlow left it unfinished by default. Every single clickable widget should have a Focus parameter.

Can someone help me extend the Flutter Focus Class properly so that FlutterFlow will accept a Widget as the child parameter?

For No reason that I can see, Some widgets do not have a FocusNode Property, such as DropDownMenus. I have a case where I now need to WRAP my dropdown with a Custom Focus Widget.

I'm only guessing that I can extend the Focus Class and do nothing more than send it my DropDown Widget as a child parameter....

However, I am not smart enough to code this in this codeless environment... Below is my initial failing class extension... It is a Custom Widget that does nothing more than ATTEMPT to extend the focus class....:

No compile errors (on this version)....

'''

// Automatic FlutterFlow imports
import '/backend/sqlite/sqlite_manager.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

class MyFocusWidget extends Focus {
  const MyFocusWidget(
    this.width,
    this.height,
    Key? key,
    //FocusNode? node,
    bool autofocus,
    Widget? child,
  ) : super(
            key: key,
            //node: node as FocusNode,
            autofocus: autofocus,
            child: child as Widget);
  final double? width;
  final double? height;

  @override
  _MyFocusWidgetState createState() => _MyFocusWidgetState();
}

class _MyFocusWidgetState extends State<MyFocusWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: widget.width,
      height: widget.height,
      child: Text('My Widget'),
    );
  }
}

'''

3
2 replies