add popupmenu

null_safety
小赖 4 years ago
parent 9ed9003805
commit 718f7f6d18

@ -0,0 +1,40 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
class ExamplePopUpMenu extends StatefulWidget {
ExamplePopUpMenu({Key key}) : super(key: key);
@override
_ExamplePopUpMenuState createState() => _ExamplePopUpMenuState();
}
class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
@override
Widget build(BuildContext context) {
return ASScaffold(
title: 'PopUpMenu',
body: ListView(
children: [
ListTile(
title: 'PopUpMenu'.text,
trailing: Builder(
builder: (context) {
return TextButton(
child: 'test'.text,
onPressed: () {
showASPopUpMenu<int>(
context: context,
items: [
PopupMenuItem(child: 'test'.text, value: 1),
],
).then((value) {});
},
);
},
),
),
],
),
);
}
}

@ -4,6 +4,7 @@ import 'package:example/example_box.dart';
import 'package:example/example_dialog.dart';
import 'package:example/example_drawer.dart';
import 'package:example/example_listtile.dart';
import 'package:example/example_pop_up_menu.dart';
import 'package:example/example_refresh.dart';
import 'package:example/example_tag.dart';
import 'package:example/example_text_field.dart';
@ -99,6 +100,10 @@ class _MainHomeState extends State<MainHome> {
title: '选框 Box',
onPressed: () => Get.to(ExampleBox()),
),
_innerButton(
title: 'Pop Up Menu',
onPressed: () => Get.to(ExamplePopUpMenu()),
),
],
);
}

@ -8,20 +8,6 @@ packages:
relative: true
source: path
version: "0.0.4"
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
bot_toast:
dependency: transitive
description:
@ -43,13 +29,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
@ -64,13 +43,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
@ -102,11 +74,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
get:
dependency: "direct main"
description:
@ -156,13 +123,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
@ -203,20 +163,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
@ -231,13 +177,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:

@ -1,20 +1,6 @@
name: example
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
publish_to: "none"
version: 1.0.0+1
environment:
@ -33,8 +19,6 @@ dependencies:
path: ../
get:
dev_dependencies:
flutter_test:
flutter:
uses-material-design: true
assets:

@ -1,30 +0,0 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}

@ -47,6 +47,8 @@ export 'refresh/as_refresh.dart';
export 'box/as_check_box.dart';
export 'pop_up_menu/pop_up_menu.dart';
export 'tag/as_tag.dart';
export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart';

@ -0,0 +1,31 @@
import 'package:ansu_ui/utils/screen_adapter.dart';
import 'package:ansu_ui/extension/num_extension.dart';
import 'package:flutter/material.dart';
/// ##
///```dart
/// showASPopUpMenu<int>(
/// context: context,
/// items: [
/// PopupMenuItem(child: 'test'.text, value: 1),
/// ],
/// ).then((value) {});
/// ```
Future<T> showASPopUpMenu<T>({
@required BuildContext context,
@required List<PopupMenuEntry<T>> items,
}) async {
final RenderBox renderBox = context.findRenderObject();
Offset offset = renderBox.localToGlobal(Offset.zero);
return await showMenu(
context: context,
position: RelativeRect.fromLTRB(
offset.dx,
offset.dy,
screenWidth,
screenHeight,
),
items: items,
shape: RoundedRectangleBorder(borderRadius: 10.radius),
);
}
Loading…
Cancel
Save