Skip to content

Instantly share code, notes, and snippets.

@aslamanver
Created October 3, 2019 11:09
Show Gist options
  • Save aslamanver/e1360071f9caff009101eb190a38d4cb to your computer and use it in GitHub Desktop.
Save aslamanver/e1360071f9caff009101eb190a38d4cb to your computer and use it in GitHub Desktop.
Flutter custom inheritance - Extending the base class
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