-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
219 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...lutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Feedback_ProgressIndicator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Feedback_ProgressIndicator()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Feedback_ProgressIndicator extends StatelessWidget { | ||
Feedback_ProgressIndicator({super.key}); | ||
|
||
final selected = false.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch(builder: (context) { | ||
return Row(children: [ | ||
IconButton( | ||
isSelected: selected.value, | ||
selectedIcon: const Icon(Icons.pause), | ||
icon: const Icon(Icons.play_arrow), | ||
onPressed: () { | ||
selected.value = !selected.value; | ||
}, | ||
), | ||
CircularProgressIndicator(value: selected.value ? null : 0.9), | ||
Expanded( | ||
child: LinearProgressIndicator(value: selected.value ? null : 0.9), | ||
), | ||
]); | ||
}); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Feedback_RefreshIndicator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Feedback_RefreshIndicator()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Feedback_RefreshIndicator extends StatelessWidget { | ||
Feedback_RefreshIndicator({super.key}); | ||
|
||
final selected = false.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column(children: [ | ||
const Text("RefreshIndicator 下拉刷新(Pull down to refresh)"), | ||
SizedBox( | ||
height: 200, | ||
child: RefreshIndicator( | ||
onRefresh: () async { | ||
selected.value = true; | ||
await Future.delayed(const Duration(seconds: 3)); // mock delay | ||
selected.value = false; | ||
}, | ||
child: ListView.builder( | ||
physics: const AlwaysScrollableScrollPhysics(), | ||
itemCount: 5, // 示例数据数量 | ||
itemBuilder: (context, index) { | ||
return ListTile(title: Text('Item ${index + 1}/5')); | ||
}, | ||
), | ||
), | ||
), | ||
]); | ||
}, | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Feedback_SnackBar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
main() { | ||
runApp(const MaterialApp(home: Scaffold(body: Feedback_SnackBar()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Feedback_SnackBar extends StatelessWidget { | ||
const Feedback_SnackBar({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TextButton( | ||
onPressed: () { | ||
final snackBar = SnackBar( | ||
behavior: SnackBarBehavior.floating, | ||
content: const Text('SnackBar'), | ||
action: SnackBarAction( | ||
label: 'Close', | ||
onPressed: () {}, | ||
), | ||
); | ||
|
||
ScaffoldMessenger.of(context).hideCurrentSnackBar(); | ||
ScaffoldMessenger.of(context).showSnackBar(snackBar); | ||
}, | ||
child: const Text( | ||
'SnackBar', | ||
style: TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_Switch.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_Switch()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_Switch extends StatelessWidget { | ||
Form_Switch({super.key}); | ||
|
||
final Value<bool> switch1 = false.signal(); | ||
final Value<bool> switchListTile1 = false.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: <Widget>[ | ||
const Text("Switch"), | ||
Switch(value: switch1.value, onChanged: (value) => switch1.value = value), | ||
Switch(value: switch1.value, onChanged: null), | ||
const Divider(), | ||
const Text("SwitchListTile"), | ||
SwitchListTile(title: const Text("enable"), value: switchListTile1.value, onChanged: (value) => switchListTile1.value = value), | ||
SwitchListTile(title: const Text("disable"), value: switchListTile1.value, onChanged: null), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Form_TextField.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Form_TextField()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Form_TextField extends StatelessWidget { | ||
Form_TextField({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch( | ||
builder: (context) { | ||
return const Column( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: <Widget>[ | ||
TextField( | ||
obscureText: true, | ||
decoration: InputDecoration(border: OutlineInputBorder(), labelText: 'Password'), | ||
), | ||
SizedBox(height: 10), | ||
TextField( | ||
maxLength: 10, | ||
maxLengthEnforcement: MaxLengthEnforcement.none, | ||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
labelText: '手机号/Phone', | ||
errorText: '手机号不能为空/phone should not empty', | ||
), | ||
), | ||
SizedBox(height: 10), | ||
TextField( | ||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
labelText: 'disable ', | ||
enabled: false, | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters