Answers for "search widget flutter"

3

flutter inhereted widget

class MyInherited extends InheritedWidget {
  const MyInherited({
    Key? key,
    required Widget child,
  }) : super(key: key, child: child);


  // Here be dragons: null check (!) used, but if there's no
  // MyInhereted over where you used it this will throw.
  static MyInherited of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<MyInherited>()!;
  }

  //if you have properties, it should look something like:
  // bool updateShouldNotify(MyInherited old) => old.prop !== new.prop;
  
  //if you don't: 
  @override
  bool updateShouldNotify(MyInherited old) => false;
}
Posted by: Guest on December-03-2020
3

get position of a widget in screen flutter

extension GlobalKeyEx on GlobalKey {
  Rect get globalPaintBounds {
    final renderObject = currentContext?.findRenderObject();
    var translation = renderObject?.getTransformTo(null)?.getTranslation();
    if (translation != null && renderObject.paintBounds != null) {
      return renderObject.paintBounds
          .shift(Offset(translation.x, translation.y));
    } else {
      return null;
    }
  }
}
Posted by: Guest on July-10-2020
0

searchQueryBuilder: (query, list) flutter

if (text.length > 1) {
  setState(() {
    tempSearchStore = _listPkh.documents.where((d) {
      if (d['nama'].toLowerCase().indexOf(text) > -1) {
        return true;
      } else if (d['alamat'].toLowerCase().indexOf(text) > -1) {
        return true;
      }
      return false;
    }).toList();
  });
} else {
  setState(() {
    tempSearchStore = _listPkh.documents;
  });
}
Posted by: Guest on November-21-2020

Browse Popular Code Answers by Language