1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Super Constructor Demo',
debugShowCheckedModeBanner: false,
home: Material(
child: CustomCenter(
child: Text(
'Super Constructor Demo',
),
),
),
);
}
}
class CustomCenter extends Align {
// 改造前
//const Center({ Key? key, double? widthFactor, double? heightFactor, Widget? child })
// : super(key: key, widthFactor: widthFactor, heightFactor: heightFactor, child: child);
// 改造后
const CustomCenter(
{super.key, super.widthFactor, super.heightFactor, super.child});
}
|