Last active
December 11, 2018 15:32
-
-
Save jromero/b9b28abcec0d961d477c173186d95ee9 to your computer and use it in GitHub Desktop.
SO: 53723294 repro
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
import 'package:flutter/material.dart'; | |
import 'package:virgil/virgil.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Inferno( | |
{ | |
'/': (context, argumets) => HomePage(), | |
'/detailspage': (context, arguments) => DetailsPage(arguments), | |
}, | |
).home(context), | |
); | |
} | |
} | |
class HomePage extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() { | |
// TODO: implement createState | |
return _HomePageState(); | |
} | |
} | |
class _HomePageState extends State<HomePage> { | |
int _currentIndex = 0; | |
final List<Widget> _childnav = [ | |
TabPage("Movies"), | |
TabPage("Series"), | |
TabPage("Support") | |
]; | |
@override | |
Widget build(BuildContext context) { | |
// TODO: implement build | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('...'), | |
actions: <Widget>[ | |
IconButton( | |
icon: Icon(Icons.search), | |
onPressed: () {}, | |
) | |
], | |
), | |
body: _childnav[_currentIndex], | |
bottomNavigationBar: BottomNavigationBar( | |
onTap: (index) { | |
print("Tab: $index"); | |
setState(() { | |
_currentIndex = index; | |
}); | |
}, | |
currentIndex: _currentIndex, //this property defines current active tab | |
items: [ | |
BottomNavigationBarItem( | |
icon: Icon(Icons.movie), title: Text('Movies')), | |
BottomNavigationBarItem(icon: Icon(Icons.tv), title: Text('Series')), | |
BottomNavigationBarItem(icon: Icon(Icons.help), title: Text('Help')) | |
], | |
), | |
); | |
} | |
} | |
class TabPage extends StatelessWidget { | |
final String _title; | |
const TabPage(this._title, {Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Column( | |
children: <Widget>[ | |
Text(_title), | |
FutureBuilder<List<String>>( | |
future: _fetchlist(), | |
builder: (context, snapshot) { | |
if (snapshot.hasData) { | |
print(snapshot.data[1]); | |
return Expanded( | |
child: ListView.builder( | |
itemCount: snapshot.data.length, | |
itemBuilder: (context, index) { | |
final val = snapshot.data[index]; | |
return InkWell( | |
onTap: () { | |
final args = [ | |
"string1", | |
1, | |
0.0 | |
]; | |
Virgil.pushNamed(context, '/detailspage', arguments: args); | |
}, | |
child: Container( | |
padding: EdgeInsets.all(5.0), | |
height: 300, | |
child: Text(val), | |
), | |
); | |
}, | |
), | |
); | |
} | |
return Center( | |
child: CircularProgressIndicator(), | |
); | |
}, | |
) | |
], | |
), | |
); | |
} | |
Future<List<String>> _fetchlist() { | |
return Future.value(["One", "Two"]); | |
} | |
} | |
class DetailsPage extends StatelessWidget { | |
final List<Object> _args; | |
const DetailsPage(this._args, {Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: CustomScrollView( | |
slivers: <Widget>[ | |
SliverAppBar( | |
title: Text(_args[0]), | |
leading: IconButton( | |
onPressed: () => Navigator.pop(context), | |
icon: Icon(Icons.clear), | |
), | |
) | |
], | |
), | |
); | |
} | |
} |
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
name: stackoverflow | |
description: A new Flutter project. | |
# The following defines the version and build number for your application. | |
# A version number is three numbers separated by dots, like 1.2.43 | |
# followed by an optional build number separated by a +. | |
# Both the version and the builder number may be overridden in flutter | |
# build by specifying --build-name and --build-number, respectively. | |
# Read more about versioning at semver.org. | |
version: 1.0.0+1 | |
environment: | |
sdk: ">=2.0.0-dev.68.0 <3.0.0" | |
dependencies: | |
flutter: | |
sdk: flutter | |
virgil: 0.8.0 | |
# The following adds the Cupertino Icons font to your application. | |
# Use with the CupertinoIcons class for iOS style icons. | |
cupertino_icons: ^0.1.2 | |
dev_dependencies: | |
flutter_test: | |
sdk: flutter | |
# For information on the generic Dart part of this file, see the | |
# following page: https://www.dartlang.org/tools/pub/pubspec | |
# The following section is specific to Flutter. | |
flutter: | |
# The following line ensures that the Material Icons font is | |
# included with your application, so that you can use the icons in | |
# the material Icons class. | |
uses-material-design: true | |
# To add assets to your application, add an assets section, like this: | |
# assets: | |
# - images/a_dot_burr.jpeg | |
# - images/a_dot_ham.jpeg | |
# An image asset can refer to one or more resolution-specific "variants", see | |
# https://flutter.io/assets-and-images/#resolution-aware. | |
# For details regarding adding assets from package dependencies, see | |
# https://flutter.io/assets-and-images/#from-packages | |
# To add custom fonts to your application, add a fonts section here, | |
# in this "flutter" section. Each entry in this list should have a | |
# "family" key with the font family name, and a "fonts" key with a | |
# list giving the asset and other descriptors for the font. For | |
# example: | |
# fonts: | |
# - family: Schyler | |
# fonts: | |
# - asset: fonts/Schyler-Regular.ttf | |
# - asset: fonts/Schyler-Italic.ttf | |
# style: italic | |
# - family: Trajan Pro | |
# fonts: | |
# - asset: fonts/TrajanPro.ttf | |
# - asset: fonts/TrajanPro_Bold.ttf | |
# weight: 700 | |
# | |
# For details regarding fonts from package dependencies, | |
# see https://flutter.io/custom-fonts/#from-packages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment