You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.9 KiB
72 lines
1.9 KiB
4 years ago
|
import 'package:ansu_ui/ansu_ui.dart';
|
||
4 years ago
|
import 'package:example/codeviewer/code_segments.dart';
|
||
|
import 'package:example/common/code_view.dart';
|
||
4 years ago
|
import 'package:flutter/material.dart';
|
||
4 years ago
|
import 'package:get/get.dart';
|
||
4 years ago
|
|
||
|
class ExampleNumericButton extends StatefulWidget {
|
||
|
ExampleNumericButton({Key key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_ExampleNumericButtonState createState() => _ExampleNumericButtonState();
|
||
|
}
|
||
|
|
||
|
class _ExampleNumericButtonState extends State<ExampleNumericButton> {
|
||
|
_showSnack(BuildContext context, String title) {
|
||
|
Scaffold.of(context).showSnackBar(
|
||
|
SnackBar(content: Text(title)),
|
||
|
);
|
||
|
}
|
||
|
|
||
4 years ago
|
int _pickedValue = 0;
|
||
4 years ago
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return ASScaffold(
|
||
|
title: '数量选择器',
|
||
4 years ago
|
actions: [
|
||
|
IconButton(
|
||
|
icon: Icon(
|
||
|
Icons.code,
|
||
|
color: Colors.black54,
|
||
|
),
|
||
|
onPressed: () => Get.to(
|
||
|
CodeView(
|
||
|
text: (context) => CodeSegments.numericButton(context),
|
||
|
),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
4 years ago
|
body: Builder(
|
||
|
builder: (context) {
|
||
|
return ListView(
|
||
|
children: [
|
||
4 years ago
|
// BEGIN numericButton
|
||
4 years ago
|
ListTile(
|
||
|
title: Text(_pickedValue.toString()),
|
||
|
subtitle: Text('一般用法'),
|
||
|
trailing: ASNumericButton(
|
||
|
initValue: _pickedValue,
|
||
|
maxValue: 10,
|
||
|
onChange: (value) {
|
||
|
setState(() {
|
||
|
_pickedValue = value;
|
||
|
});
|
||
|
},
|
||
|
reachMax: (value) {
|
||
|
_showSnack(context, 'reach max');
|
||
|
},
|
||
|
reachMin: (value) {
|
||
|
_showSnack(context, 'reach min');
|
||
|
},
|
||
|
),
|
||
|
),
|
||
4 years ago
|
|
||
|
// END
|
||
4 years ago
|
],
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|