main.dart 1.67 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'package:flutter/material.dart';
6
import 'package:flutter/services.dart';
7

8 9 10 11
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  const MethodChannel channel = MethodChannel('com.example.abstract_method_smoke_test');
  await channel.invokeMethod<void>('show_keyboard');
12
  runApp(const MyApp());
13
  print('Test succeeded');
14
}
15 16

class MyApp extends StatelessWidget {
17
  const MyApp({super.key});
18

19 20 21 22 23 24 25
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
26
      home: const HomePage(),
27 28 29 30 31
    );
  }
}

class HomePage extends StatefulWidget {
32
  const HomePage({super.key});
33

34
  @override
35
  State<HomePage> createState() => _HomePage();
36 37 38 39 40 41 42 43 44
}

class _HomePage extends State<HomePage> {
  @override
  void initState() {
    super.initState();

    // Trigger the second route.
    // https://github.com/flutter/flutter/issues/40126
45
    WidgetsBinding.instance.addPostFrameCallback((_) async {
46
      Navigator.of(context).push(
47
          MaterialPageRoute<void>(builder: (_) => const SecondPage()));
48 49 50 51 52 53 54 55 56 57
    });
  }

  @override
  Widget build(BuildContext context) {
    return const Scaffold();
  }
}

class SecondPage extends StatelessWidget {
58
  const SecondPage({super.key});
59

60 61
  @override
  Widget build(BuildContext context) {
62
    return const Scaffold(
63
      body: Column(
64
        children: <Widget>[
65
          Expanded(
66
            child: AndroidView(viewType: 'simple')
67 68 69 70 71
          ),
        ],
      ),
    );
  }
72
}