class SliderDemo extends StatefulWidget {
@override
_SliderDemoState createState() => _SliderDemoState();
}
class _SliderDemoState extends State<SliderDemo> {
double _sliderValue = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,children: [
Text('值:$_sliderValue'),Slider(
value: _sliderValue,onChanged: (v){
setState(() {
_sliderValue = v;
});
},)
],),);
}
}
Slider(
value: _sliderValue,min: 1,max: 100,onChanged: (v){
setState(() {
_sliderValue = v;
});
},)
Slider(
value: _sliderValue,min: 0,divisions: 4,)
Slider(
value: _sliderValue,label: '$_sliderValue',)
Slider(
activeColor: Colors.red,inactiveColor: Colors.blue,value: _sliderValue,)
SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTrackColor: Color(0xff404080),thumbColor: Colors.blue,overlayColor: Colors.green,valueIndicatorColor: Colors.purpleAccent),child: Slider(
value: _sliderValue,onChanged: (v) {
setState(() {
_sliderValue = v;
});
},)
SliderTheme(
data: SliderTheme.of(context).copyWith(
valueIndicatorShape: PaddleSliderValueIndicatorShape(),)
RangeValues _rangeValues = RangeValues(0,25);
RangeSlider(
values: _rangeValues,labels: RangeLabels('${_rangeValues.start}','${_rangeValues.end}'),onChanged: (v) {
setState(() {
_rangeValues = v;
});
},
double _sliderValue = 0;
CupertinoSlider(
value: _sliderValue,onChanged: (v) {
setState(() {
_sliderValue = v;
});
},)
Slider.adaptive(
value: _sliderValue,)
RaisedButton(
child: Text('弹出日期组件'),onPressed: () async {
await showDatePicker(
context: context,initialDate: DateTime.now(),firstDate: DateTime(2010),lastDate: DateTime(2025),);
var result = await showDatePicker(
context: context,initialEntryMode: DatePickerEntryMode.input,);
var result = await showDatePicker(
context: context,initialDatePickerMode: DatePickerMode.year,);
var result = await showDatePicker(
context: context,helpText: '选则日期',cancelText: '取消',confirmText: '确定',);
var result = await showDatePicker(
context: context,errorFormatText: '错误的日期格式',errorInvalidText: '日期格式非法',fieldHintText: '月/日/年',fieldLabelText: '填写日期',);
var result = await showDatePicker(
context: context,selectableDayPredicate: (date) {
return date.difference(DateTime.now()).inMilliseconds < 0;
},);
var result = await showDatePicker(
context: context,builder: (context,child){
return Theme(
data: ThemeData.dark(),child: child,);
}
);
var result = await showDatePicker(
context: context,);
print('$result');
CalendarDatePicker(
initialDate: DateTime.now(),onDateChanged: (d) {
print('$d');
},)
RaisedButton(
child: Text('范围日期'),onPressed: () async {
var date = showDateRangePicker(context: context,lastDate: DateTime(2025));
},
dependencies:
flutter_localizations:
sdk: flutter
MaterialApp(
title: 'Flutter Demo',localizationsDelegates: [
GlobalMaterialLocalizations.delegate,GlobalWidgetsLocalizations.delegate,GlobalCupertinoLocalizations.delegate,],supportedLocales: [
const Locale('zh'),const Locale('en'),...
var result = await showDatePicker(
context: context,);
var result = await showDatePicker(
context: context,locale: Locale('zh')
);
RaisedButton(
child: Text('弹出时间选择器'),onPressed: () async {
var result =
showTimePicker(context: context,initialTime: TimeOfDay.now());
},)
var result = showTimePicker(
context: context,initialTime: TimeOfDay.now(),initialEntryMode: TimePickerEntryMode.input);
var result = showTimePicker(
context: context,initialEntryMode: TimePickerEntryMode.input,helpText: '选择时间',confirmText: '确定');
var result = showTimePicker(
context: context,builder: (BuildContext context,Widget child) {
return MediaQuery(
data: MediaQuery.of(context)
.copyWith(alwaysUse24HourFormat: true),);
},);
var result = showTimePicker(
context: context,Widget child) {
return Theme(
data: ThemeData.dark(),);
dependencies:
flutter_localizations:
sdk: flutter
MaterialApp(
title: 'Flutter Demo',...
RaisedButton(
child: Text('弹出时间选择器'),)
var result = showTimePicker(
context: context,Widget child) {
return Localizations(
locale: Locale('en'),delegates: [
GlobalMaterialLocalizations.delegate,);
class CupertinoDatePickerDemo extends StatefulWidget {
@override
_CupertinoDatePickerDemoState createState() => _CupertinoDatePickerDemoState();
}
class _CupertinoDatePickerDemoState extends State<CupertinoDatePickerDemo> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),body: Center(
child: Container(
height: 200,color: Colors.grey.withOpacity(.5),child: CupertinoDatePicker(
initialDateTime: DateTime.now(),onDateTimeChanged: (date) {
print('$date');
},);
}
}
CupertinoDatePicker(
initialDateTime: DateTime.now(),minimumDate: DateTime.now().add(Duration(days: -1)),maximumDate: DateTime.now().add(Duration(days: 1)),onDateTimeChanged: (date) {
print('$date');
},)
CupertinoDatePicker(
mode: CupertinoDatePickerMode.time,initialDateTime: DateTime.now(),)
CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,)
CupertinoDatePicker(
mode: CupertinoDatePickerMode.dateAndTime,)
4 | 14 | PM
July | 13 | 2012
Fri Jul 13 | 4 | 14 | PM
CupertinoDatePicker(
use24hFormat: true,)
dependencies:
flutter_localizations:
sdk: flutter
MaterialApp(
title: 'Flutter Demo',...
CupertinoDatePicker(
initialDateTime: DateTime.now(),)
Localizations(
locale: Locale('zh'),delegates: [
GlobalMaterialLocalizations.delegate,child: CupertinoDatePicker(
initialDateTime: DateTime.now(),onDateTimeChanged: (date) {
print('$date');
},)
CupertinoTimerPicker(onTimerDurationChanged: (time) {
print('$time');
})
16 hours | 14 min
14 min | 43 sec
16 hours | 14 min | 43 sec
CupertinoTimerPicker(
mode: CupertinoTimerPickerMode.hm,onTimerDurationChanged: (time) {
print('$time');
})
CupertinoTimerPicker(
initialTimerDuration: Duration(
hours: DateTime.now().hour,minutes: DateTime.now().minute,seconds: DateTime.now().second),onTimerDurationChanged: (time) {
print('$time');
})
CupertinoTimerPicker(
minuteInterval: 5,secondInterval: 5,onTimerDurationChanged: (time) {
print('$time');
})
dependencies:
flutter_localizations:
sdk: flutter
MaterialApp(
title: 'Flutter Demo',...
CupertinoTimerPicker(onTimerDurationChanged: (time) {
print('$time');
})
Localizations(
locale: Locale('zh'),child: CupertinoTimerPicker(onTimerDurationChanged: (time) {
print('$time');
}),)
InteractiveViewer(
child: Image.asset('assets/images/go_board_09x09.png'),)
InteractiveViewer(
alignPanAxis: true,child: Image.asset('assets/images/go_board_09x09.png'),)
InteractiveViewer(
maxScale: 2,minScale: 1,scaleEnabled: true,)
class InteractiveViewerDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
const int _rowCount = 20;
const int _columnCount = 10;
return Scaffold(
appBar: AppBar(),body: Center(
child: Container(
height: 300,width: 300,child: InteractiveViewer(
constrained: false,child: Table(
columnWidths: <int,TableColumnWidth>{
for (int column = 0; column < _columnCount; column += 1)
column: const FixedColumnWidth(100.0),},children: <TableRow>[
for (int row = 0; row < _rowCount; row += 1)
TableRow(
children: <Widget>[
for (int column = 0; column < _columnCount; column += 1)
Container(
height: 50,color: row % 2 + column % 2 == 1
? Colors.red
: Colors.green,);
}
}
InteractiveViewer(
child: Image.asset('assets/images/go_board_09x09.png'),onInteractionStart: (ScaleStartDetails scaleStartDetails){
print('onInteractionStart:$scaleStartDetails');
},onInteractionUpdate: (ScaleUpdateDetails scaleUpdateDetails){
print('onInteractionUpdate:$scaleUpdateDetails');
},onInteractionEnd: (ScaleEndDetails endDetails){
print('onInteractionEnd:$endDetails');
},)
final TransformationController _transformationController =
TransformationController();
InteractiveViewer(
child: Image.asset('assets/images/go_board_09x09.png'),transformationController: _transformationController,)
var matrix = _transformationController.value.clone();
matrix.scale(1.5,1.0,1.0);
_transformationController.value = matrix;
import 'dart:math';
import 'package:flutter/material.dart';
///
/// desc:
///
class InteractiveViewerDemo extends StatefulWidget {
@override
_InteractiveViewerDemoState createState() => _InteractiveViewerDemoState();
}
class _InteractiveViewerDemoState extends State<InteractiveViewerDemo> {
final TransformationController _transformationController =
TransformationController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),body: Column(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),child: Center(
child: InteractiveViewer(
child: Image.asset('assets/images/go_board_09x09.png'),Expanded(
child: Container(),Row(
children: [
RaisedButton(
child: Text('重置'),onPressed: () {
_transformationController.value = Matrix4.identity();
},RaisedButton(
child: Text('左移'),onPressed: () {
var matrix = _transformationController.value.clone();
matrix.translate(-5.0);
_transformationController.value = matrix;
},RaisedButton(
child: Text('放大'),onPressed: () {
var matrix = _transformationController.value.clone();
matrix.scale(1.5,1.0);
_transformationController.value = matrix;
},);
}
}
本站采用系统自动发货方式,付款后即出现下载入口,如有疑问请咨询在线客服!
售后时间:早10点 - 晚11:30点Copyright © 2024 jiecseo.com All rights reserved. 粤ICP备18085929号
欢迎光临【捷杰建站】,本站所有资源仅供学习与参考,禁止用于商业用途或从事违法行为!
技术营运:深圳市晟艺互动传媒有限公司