Skip to content

Instantly share code, notes, and snippets.

child: RaisedButton(
child: Text('go to first tab'),
onPressed: () {
_tabController.animateTo(0, curve: Curves.ease, duration: Duration(seconds: 2));
},
),
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
initialRoute: '/',
routes: {
'/': (BuildContext context) => HomePage(),
'/page1': (BuildContext context) => Page1(),
'/page4': (BuildContext context) => Page4(),
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RichText Widget Demo'),
),
body: Center(
child: ListView(
padding: const EdgeInsets.all(20.0),
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RichText Widget Demo'),
),
body: Center(
child: ListView(
padding: const EdgeInsets.all(20.0),
children: <Widget>[
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RichText Widget Demo'),
),
body: Center(
child: ListView(
padding: const EdgeInsets.all(20.0),
children: <Widget>[
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BottomAppBar demo'),
),
body: Center(
child: Text('body'),
),
class _ClickCounterState extends State<ClickCounter> {
int _count = 0;
var keys = [1, 2, 3];
var colors = [Colors.red, Colors.blue, Colors.green];
var borderRadius = [50.0, 30.0, 0.0];
Widget createBox(int key) => Container(
decoration: BoxDecoration(
color: colors[key],
borderRadius: BorderRadius.circular(borderRadius[key]),
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
}
class _MyHomePageState extends State<MyHomePage> {
AlertDialog _dialog(String title) {
return AlertDialog(
title: Text(title),
actions: <Widget>[
FlatButton(
child: Text('back'),
onPressed: () {
Navigator.pop(context);
},