Created
October 3, 2019 11:09
-
-
Save aslamanver/e1360071f9caff009101eb190a38d4cb to your computer and use it in GitHub Desktop.
Flutter custom inheritance - Extending the base class
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'; | |
class MainScreen extends StatefulWidget { | |
@override | |
_MainScreenState createState() => _MainScreenState(); | |
} | |
class _MainScreenState extends _BaseStatefulState<MainScreen> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center(child: Text("Test")), | |
); | |
} | |
} | |
abstract class _BaseStatefulState<T extends StatefulWidget> extends State<T> { | |
_BaseStatefulState() { | |
// Parent constructor | |
} | |
void baseMethod() { | |
// Parent method | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment