@@ -2,29 +2,26 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ScrollDirection].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
/// Flutter code sample for [ScrollDirection].
|
||||
|
||||
void main() => runApp(const ExampleApp());
|
||||
|
||||
class ExampleApp extends StatelessWidget {
|
||||
const ExampleApp({super.key});
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyWidget extends StatefulWidget {
|
||||
const MyWidget({ super.key });
|
||||
const MyWidget({super.key});
|
||||
|
||||
@override
|
||||
State<MyWidget> createState() => _MyWidgetState();
|
||||
@@ -41,30 +38,30 @@ class _MyWidgetState extends State<MyWidget> {
|
||||
|
||||
Widget _getArrows() {
|
||||
final Widget arrow;
|
||||
switch(_axisDirection) {
|
||||
switch (_axisDirection) {
|
||||
case AxisDirection.up:
|
||||
arrow = const Icon(Icons.arrow_upward_rounded);
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[ arrow, arrow ],
|
||||
children: <Widget>[arrow, arrow],
|
||||
);
|
||||
case AxisDirection.down:
|
||||
arrow = const Icon(Icons.arrow_downward_rounded);
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[ arrow, arrow ],
|
||||
children: <Widget>[arrow, arrow],
|
||||
);
|
||||
case AxisDirection.left:
|
||||
arrow = const Icon(Icons.arrow_back_rounded);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[ arrow, arrow ],
|
||||
children: <Widget>[arrow, arrow],
|
||||
);
|
||||
case AxisDirection.right:
|
||||
arrow = const Icon(Icons.arrow_forward_rounded);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[ arrow, arrow ],
|
||||
children: <Widget>[arrow, arrow],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -148,7 +145,7 @@ class _MyWidgetState extends State<MyWidget> {
|
||||
|
||||
bool _handleNotification(UserScrollNotification notification) {
|
||||
if (notification.direction != scrollDirection) {
|
||||
setState((){
|
||||
setState(() {
|
||||
scrollDirection = notification.direction;
|
||||
});
|
||||
}
|
||||
@@ -197,7 +194,7 @@ class _MyWidgetState extends State<MyWidget> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user