main.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import 'package:flutter/material.dart';
  2. import "./example_button.dart";
  3. void main() {
  4. runApp(const MyApp());
  5. }
  6. class MyApp extends StatelessWidget {
  7. const MyApp({Key? key}) : super(key: key);
  8. // This widget is the root of your application.
  9. @override
  10. Widget build(BuildContext context) {
  11. return MaterialApp(
  12. title: 'Flutter Demo',
  13. theme: ThemeData(
  14. // This is the theme of your application.
  15. //
  16. // Try running your application with "flutter run". You'll see the
  17. // application has a blue toolbar. Then, without quitting the app, try
  18. // changing the primarySwatch below to Colors.green and then invoke
  19. // "hot reload" (press "r" in the console where you ran "flutter run",
  20. // or simply save your changes to "hot reload" in a Flutter IDE).
  21. // Notice that the counter didn't reset back to zero; the application
  22. // is not restarted.
  23. primarySwatch: Colors.blue,
  24. ),
  25. home: const MyHomePage(title: 'AppFlowy Popover Example'),
  26. );
  27. }
  28. }
  29. class MyHomePage extends StatefulWidget {
  30. const MyHomePage({Key? key, required this.title}) : super(key: key);
  31. // This widget is the home page of your application. It is stateful, meaning
  32. // that it has a State object (defined below) that contains fields that affect
  33. // how it looks.
  34. // This class is the configuration for the state. It holds the values (in this
  35. // case the title) provided by the parent (in this case the App widget) and
  36. // used by the build method of the State. Fields in a Widget subclass are
  37. // always marked "final".
  38. final String title;
  39. @override
  40. State<MyHomePage> createState() => _MyHomePageState();
  41. }
  42. class _MyHomePageState extends State<MyHomePage> {
  43. @override
  44. Widget build(BuildContext context) {
  45. // This method is rerun every time setState is called, for instance as done
  46. // by the _incrementCounter method above.
  47. //
  48. // The Flutter framework has been optimized to make rerunning build methods
  49. // fast, so that you can just rebuild anything that needs updating rather
  50. // than having to individually change instances of widgets.
  51. return Scaffold(
  52. appBar: AppBar(
  53. // Here we take the value from the MyHomePage object that was created by
  54. // the App.build method, and use it to set our appbar title.
  55. title: Text(widget.title),
  56. ),
  57. body: Row(children: [
  58. Column(children: [
  59. ExampleButton(
  60. label: "Left top",
  61. targetAnchor: Alignment.bottomLeft,
  62. offset: const Offset(0, 10),
  63. ),
  64. Expanded(child: Container()),
  65. ExampleButton(
  66. label: "Left bottom",
  67. followerAnchor: Alignment.bottomLeft,
  68. offset: const Offset(0, -10),
  69. ),
  70. ]),
  71. Expanded(
  72. child: Column(
  73. mainAxisAlignment: MainAxisAlignment.center,
  74. children: <Widget>[
  75. ExampleButton(
  76. label: "Top",
  77. targetAnchor: Alignment.bottomCenter,
  78. followerAnchor: Alignment.topCenter,
  79. offset: const Offset(0, 10),
  80. ),
  81. Expanded(
  82. child: Column(
  83. mainAxisAlignment: MainAxisAlignment.center,
  84. crossAxisAlignment: CrossAxisAlignment.center,
  85. children: [
  86. ExampleButton(
  87. label: "Central",
  88. targetAnchor: Alignment.bottomCenter,
  89. followerAnchor: Alignment.topCenter,
  90. offset: const Offset(0, 10),
  91. ),
  92. ],
  93. ),
  94. ),
  95. ExampleButton(
  96. label: "Bottom",
  97. targetAnchor: Alignment.topCenter,
  98. followerAnchor: Alignment.bottomCenter,
  99. offset: const Offset(0, -10),
  100. ),
  101. ],
  102. ),
  103. ),
  104. Column(
  105. children: [
  106. ExampleButton(
  107. label: "Right top",
  108. targetAnchor: Alignment.bottomRight,
  109. followerAnchor: Alignment.topRight,
  110. offset: const Offset(0, 10),
  111. ),
  112. Expanded(child: Container()),
  113. ExampleButton(
  114. label: "Right bottom",
  115. targetAnchor: Alignment.topRight,
  116. followerAnchor: Alignment.bottomRight,
  117. offset: const Offset(0, -10),
  118. ),
  119. ],
  120. )
  121. ]),
  122. );
  123. }
  124. }