I have this on scaffold_context.dart
:
import 'package:flutter/material.dart';
extension Context on Scaffold {
static Scaffold builder({ AppBar appBar, Function (BuildContext context) buildContext, Widget body }) {
return Scaffold(
appBar: appBar,
body: Builder(builder: (context) {
buildContext(context);
return body;
})
);
}
}
But when I tried to call it on my UI Widget:
import 'scaffold_context.dart';
...
BuildContext _context;
@override
Widget build(BuildContext context) {
return Scaffold.builder(
appBar: AppBar(title: "Hello world"),
buildContext: (context) => _context = context,
body: Center(child: Text("Hello world")
);
}
I got an error:
The method 'builder' isn't defined for the class 'Scaffold'.
How am I supposed to use this extension?