Created
December 11, 2019 13:07
-
-
Save knaeckeKami/1779258c09a76b2b44dd8d9da50a365d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
typedef Widget FormWidgetBuilder<T>(T t); | |
class GenericShizzle<T> extends StatefulWidget { | |
final FormWidgetBuilder<T> builder; | |
const GenericShizzle({ | |
this.builder, | |
}); | |
@override | |
GenericShizzleState<T> createState() { | |
return GenericShizzleState<T>(); | |
} | |
} | |
class GenericShizzleState<T> extends State<GenericShizzle<T>> { | |
@override | |
Widget build(BuildContext context) { | |
return Text( | |
"my builder is of type:" + widget.builder.runtimeType.toString()); | |
} | |
} | |
void main() { | |
runApp( | |
MaterialApp( | |
home: Scaffold( | |
body: Center( | |
child: GenericShizzle( | |
builder: (int i) => Text(i.toString()), | |
), | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment