mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -10,20 +10,11 @@ final scheme = Platform.environment['SERVER_SCHEME'] ?? 'http';
|
||||
final serverUrl = Uri.parse('$scheme://$host:$port/');
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const MyApp(
|
||||
getCount: getCount,
|
||||
increment: increment,
|
||||
),
|
||||
);
|
||||
runApp(const MyApp(getCount: getCount, increment: increment));
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({
|
||||
super.key,
|
||||
required this.getCount,
|
||||
required this.increment,
|
||||
});
|
||||
const MyApp({super.key, required this.getCount, required this.increment});
|
||||
|
||||
final Future<int> Function() getCount;
|
||||
final Future<int> Function(int) increment;
|
||||
@@ -32,9 +23,7 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
colorSchemeSeed: Colors.blue,
|
||||
),
|
||||
theme: ThemeData(colorSchemeSeed: Colors.blue),
|
||||
home: MyHomePage(
|
||||
title: 'Flutter Demo Home Page',
|
||||
getCount: getCount,
|
||||
@@ -74,26 +63,24 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
void _incrementCounter() {
|
||||
localClicks += 1;
|
||||
setState(() => isWriting = true);
|
||||
widget.increment(localClicks).then(
|
||||
(int val) => setState(
|
||||
() {
|
||||
_counter = val;
|
||||
// Leave this up for at least a split second
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 200),
|
||||
() => setState(() => isWriting = false),
|
||||
);
|
||||
},
|
||||
),
|
||||
widget
|
||||
.increment(localClicks)
|
||||
.then(
|
||||
(int val) => setState(() {
|
||||
_counter = val;
|
||||
// Leave this up for at least a split second
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 200),
|
||||
() => setState(() => isWriting = false),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
appBar: AppBar(title: Text(widget.title)),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
@@ -4,7 +4,7 @@ publish_to: "none"
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
cupertino_icons: ^1.0.2
|
||||
|
||||
@@ -9,9 +9,10 @@ import 'package:shelf_router/shelf_router.dart';
|
||||
int count = 0;
|
||||
|
||||
// Configure routes.
|
||||
final _router = Router()
|
||||
..post('/', _incrementHandler)
|
||||
..get('/', _getValueHandler);
|
||||
final _router =
|
||||
Router()
|
||||
..post('/', _incrementHandler)
|
||||
..get('/', _getValueHandler);
|
||||
|
||||
Future<Response> _incrementHandler(Request request) async {
|
||||
final incr = Increment.fromJson(json.decode(await request.readAsString()));
|
||||
@@ -27,8 +28,9 @@ void main(List<String> args) async {
|
||||
final ip = InternetAddress.anyIPv4;
|
||||
|
||||
// Configure a pipeline that logs requests.
|
||||
final handler =
|
||||
Pipeline().addMiddleware(logRequests()).addHandler(_router.call);
|
||||
final handler = Pipeline()
|
||||
.addMiddleware(logRequests())
|
||||
.addHandler(_router.call);
|
||||
|
||||
// For running in containers, we respect the PORT environment variable.
|
||||
final port = int.parse(Platform.environment['PORT'] ?? '8080');
|
||||
|
||||
@@ -4,7 +4,7 @@ version: 1.0.0
|
||||
publish_to: "none"
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
args: ^2.0.0
|
||||
|
||||
@@ -42,9 +42,7 @@ void main() {
|
||||
});
|
||||
},
|
||||
onPlatform: <String, dynamic>{
|
||||
'windows': [
|
||||
Skip('Failing on Windows CI'),
|
||||
]
|
||||
'windows': [Skip('Failing on Windows CI')],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ part of 'models.dart';
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods',
|
||||
);
|
||||
|
||||
Increment _$IncrementFromJson(Map<String, dynamic> json) {
|
||||
return _Increment.fromJson(json);
|
||||
@@ -48,15 +49,17 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? by = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
by: null == by
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
$Res call({Object? by = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
by:
|
||||
null == by
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +67,9 @@ class _$IncrementCopyWithImpl<$Res, $Val extends Increment>
|
||||
abstract class _$$IncrementImplCopyWith<$Res>
|
||||
implements $IncrementCopyWith<$Res> {
|
||||
factory _$$IncrementImplCopyWith(
|
||||
_$IncrementImpl value, $Res Function(_$IncrementImpl) then) =
|
||||
__$$IncrementImplCopyWithImpl<$Res>;
|
||||
_$IncrementImpl value,
|
||||
$Res Function(_$IncrementImpl) then,
|
||||
) = __$$IncrementImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int by});
|
||||
@@ -76,20 +80,22 @@ class __$$IncrementImplCopyWithImpl<$Res>
|
||||
extends _$IncrementCopyWithImpl<$Res, _$IncrementImpl>
|
||||
implements _$$IncrementImplCopyWith<$Res> {
|
||||
__$$IncrementImplCopyWithImpl(
|
||||
_$IncrementImpl _value, $Res Function(_$IncrementImpl) _then)
|
||||
: super(_value, _then);
|
||||
_$IncrementImpl _value,
|
||||
$Res Function(_$IncrementImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? by = null,
|
||||
}) {
|
||||
return _then(_$IncrementImpl(
|
||||
by: null == by
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
$Res call({Object? by = null}) {
|
||||
return _then(
|
||||
_$IncrementImpl(
|
||||
by:
|
||||
null == by
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +135,7 @@ class _$IncrementImpl implements _Increment {
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$IncrementImplToJson(
|
||||
this,
|
||||
);
|
||||
return _$$IncrementImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,23 +186,26 @@ class _$CountCopyWithImpl<$Res, $Val extends Count>
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? value = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
value: null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
$Res call({Object? value = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
value:
|
||||
null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CountImplCopyWith<$Res> implements $CountCopyWith<$Res> {
|
||||
factory _$$CountImplCopyWith(
|
||||
_$CountImpl value, $Res Function(_$CountImpl) then) =
|
||||
__$$CountImplCopyWithImpl<$Res>;
|
||||
_$CountImpl value,
|
||||
$Res Function(_$CountImpl) then,
|
||||
) = __$$CountImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int value});
|
||||
@@ -209,20 +216,21 @@ class __$$CountImplCopyWithImpl<$Res>
|
||||
extends _$CountCopyWithImpl<$Res, _$CountImpl>
|
||||
implements _$$CountImplCopyWith<$Res> {
|
||||
__$$CountImplCopyWithImpl(
|
||||
_$CountImpl _value, $Res Function(_$CountImpl) _then)
|
||||
: super(_value, _then);
|
||||
_$CountImpl _value,
|
||||
$Res Function(_$CountImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? value = null,
|
||||
}) {
|
||||
return _then(_$CountImpl(
|
||||
null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
$Res call({Object? value = null}) {
|
||||
return _then(
|
||||
_$CountImpl(
|
||||
null == value
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,9 +270,7 @@ class _$CountImpl implements _Count {
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CountImplToJson(
|
||||
this,
|
||||
);
|
||||
return _$$CountImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,20 +7,13 @@ part of 'models.dart';
|
||||
// **************************************************************************
|
||||
|
||||
_$IncrementImpl _$$IncrementImplFromJson(Map<String, dynamic> json) =>
|
||||
_$IncrementImpl(
|
||||
by: json['by'] as int,
|
||||
);
|
||||
_$IncrementImpl(by: json['by'] as int);
|
||||
|
||||
Map<String, dynamic> _$$IncrementImplToJson(_$IncrementImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'by': instance.by,
|
||||
};
|
||||
<String, dynamic>{'by': instance.by};
|
||||
|
||||
_$CountImpl _$$CountImplFromJson(Map<String, dynamic> json) => _$CountImpl(
|
||||
json['value'] as int,
|
||||
);
|
||||
_$CountImpl _$$CountImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CountImpl(json['value'] as int);
|
||||
|
||||
Map<String, dynamic> _$$CountImplToJson(_$CountImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'value': instance.value,
|
||||
};
|
||||
<String, dynamic>{'value': instance.value};
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Common data models required by our client and server
|
||||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
freezed_annotation: ^2.1.0
|
||||
|
||||
Reference in New Issue
Block a user