@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [BuildOwner].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
/// Flutter code sample for [BuildOwner].
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final Size size = measureWidget(const SizedBox(width: 640, height: 480));
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ErrorWidget].
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [ErrorWidget].
|
||||
|
||||
void main() {
|
||||
// Set the ErrorWidget's builder before the app is started.
|
||||
ErrorWidget.builder = (FlutterErrorDetails details) {
|
||||
@@ -28,19 +28,17 @@ void main() {
|
||||
};
|
||||
|
||||
// Start the app.
|
||||
runApp(const MyApp());
|
||||
runApp(const ErrorWidgetExampleApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
static const String _title = 'ErrorWidget Sample';
|
||||
class ErrorWidgetExampleApp extends StatefulWidget {
|
||||
const ErrorWidgetExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
State<ErrorWidgetExampleApp> createState() => _ErrorWidgetExampleAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
class _ErrorWidgetExampleAppState extends State<ErrorWidgetExampleApp> {
|
||||
bool throwError = false;
|
||||
|
||||
@override
|
||||
@@ -55,13 +53,14 @@ class _MyAppState extends State<MyApp> {
|
||||
);
|
||||
} else {
|
||||
return MaterialApp(
|
||||
title: MyApp._title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(MyApp._title)),
|
||||
appBar: AppBar(title: const Text('ErrorWidget Sample')),
|
||||
body: Center(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
setState(() { throwError = true; });
|
||||
setState(() {
|
||||
throwError = true;
|
||||
});
|
||||
},
|
||||
child: const Text('Error Prone')),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user