Created
December 2, 2019 10:19
-
-
Save mikepyts/7b63b8e5086d4606c0d25631d27d5755 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'dart:math' as math; | |
import 'dart:ui'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/scheduler.dart'; | |
import 'package:flutter/painting.dart'; | |
import 'package:flutter_issues/cupertino_web_scrollbar.dart' | |
as cupertino_scrollbar; | |
import 'package:flutter_issues/custom_scrollview.dart' as custom_scrollview; | |
export 'package:flutter/physics.dart' show Tolerance; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
final ScrollController scrollController = ScrollController(); | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
List<int> events = List.generate(100, (_) => Random().nextInt(10)); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
/// #1 Uncomment to test the issue with GestureDetector HitTestBehavior | |
/* | |
Text( | |
'Nested gesture detector with HitTestBehavior\n', | |
), | |
Text( | |
'$_counter', | |
style: Theme.of(context).textTheme.display1, | |
), | |
GestureDetector( | |
behavior: HitTestBehavior.translucent, | |
child: GestureDetector( | |
child: Container(width: 100, height: 100, color: Colors.red), | |
onTap: _incrementCounter), | |
onTap: _incrementCounterTwice, | |
) | |
*/ | |
/// #2 Uncomment to test the issue with color of nester containers with | |
/// decoration image | |
/* | |
// Decoration in child container | |
Text( | |
'Container decoration image issue with nested container\n', | |
), | |
Container( | |
width: 200, | |
height: 200, | |
color: Colors.yellow, | |
child: Container( | |
width: 100, | |
height: 100, | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
image: NetworkImage( | |
'https://flutter.dev/images/flutter-mono-81x100.png'))), | |
)), | |
Divider(), | |
// Decoration in patent container | |
Container( | |
width: 200, | |
height: 200, | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
image: NetworkImage( | |
'https://flutter.dev/images/flutter-mono-81x100.png'))), | |
child: Container( | |
width: 100, | |
height: 100, | |
color: Colors.yellow, | |
)) | |
*/ | |
/// #3 Uncomment to test the issue with Cupertino ScrollBar behavior | |
/// #3.1 Current Scrollbar behavior on the Web platform | |
/// #3.2 Custom Scrollbar behavior on the Web platform with custom Cupertino behavior | |
/// #3.2 Custom Scrollbar behavior on the Web platform with custom Cupertino behavior and dynamic size ListView children | |
/// #3.1 Uncomment to see what is current behavior with ScrollBar on | |
/// Web (Fuchsia?) platform | |
/* | |
Text( | |
'Current scrollbar behavior on web paltform\n', | |
), | |
Container( | |
width: 1100, | |
height: 500, | |
child: Scrollbar( | |
controller: widget.scrollController, | |
child: ListView.builder( | |
controller: widget.scrollController, | |
itemCount: 100, | |
itemBuilder: (_, int index) => Padding( | |
padding: EdgeInsets.all(50), | |
child: Container( | |
height: 50, width: 1000, color: Colors.red))))) | |
*/ | |
/// #3.2 Uncomment to see what is behavior with custom Cupertino ScrollBar on | |
/// Web (Fuchsia?) platform | |
/* | |
Text( | |
'Cupertino scrollbar behavior on web paltform\n', | |
), | |
Container( | |
width: 1100, | |
height: 500, | |
child: cupertino_scrollbar.CupertinoScrollbar( | |
controller: widget.scrollController, | |
child: ListView.builder( | |
controller: widget.scrollController, | |
itemCount: 100, | |
itemBuilder: (_, int index) => Padding( | |
padding: EdgeInsets.all(50), | |
child: Container( | |
height: 50, | |
width: 1000, | |
color: Colors.green))))) | |
*/ | |
/// #3.3 Uncomment to see what is behavior with custom Scrollable and ScrollView on | |
/// Web (Fuchsia?) platform which works with custom type of events inside the Scrollable | |
/* | |
Text( | |
'Cupertino scrollbar behavior on web paltform\n', | |
), | |
Container( | |
width: 1100, | |
height: 500, | |
child: cupertino_scrollbar.CupertinoScrollbar( | |
controller: widget.scrollController, | |
child: custom_scrollview.ListView.builder( | |
controller: widget.scrollController, | |
itemCount: events.length, | |
itemBuilder: (_, int index) => Padding( | |
padding: EdgeInsets.all(50), | |
child: Container( | |
height: 50, | |
width: 1000, | |
color: Colors.green))))) | |
*/ | |
], | |
), | |
), | |
); | |
} | |
void _incrementCounter() { | |
print('Increment counter once'); | |
setState(() { | |
_counter++; | |
}); | |
} | |
void _incrementCounterTwice() { | |
print('Increment counter twice'); | |
setState(() { | |
_counter++; | |
_counter++; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment