main.dart 4.3 KB

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