Skip to content

Instantly share code, notes, and snippets.

View termosa's full-sized avatar

Stanislav Termosa termosa

View GitHub Profile
@termosa
termosa / navigator_push_method.dart
Created May 22, 2019 06:18
[An Introduction to Flutter: The Interface] Navigator push method
NavigatorState navigator = Navigator.of(context);
navigator.push(
MaterialPageRoute(
builder: (context) => DifferentScreen()
)
);
@termosa
termosa / using_safe_area.dart
Created May 22, 2019 06:16
[An Introduction to Flutter: The Interface] Using SafeArea
import 'package:flutter/material.dart';
class SafeAreaExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@termosa
termosa / hundred-million-blocks.dart
Created May 22, 2019 06:14
[An Introduction to Flutter: The Interface] Hundred million blocks
import 'package:flutter/widgets.dart';
import 'dart:math';
main() => runApp(Directionality(
textDirection: TextDirection.ltr,
child: ListExample(),
));
class ListExample extends StatelessWidget {
final double cellSize = 50;
@termosa
termosa / list-view.dart
Created May 22, 2019 06:11
[An Introduction to Flutter: The Interface] ListView example
ListView(
children: [
Item(),
Item(),
],
)
@termosa
termosa / basic_scroll.dart
Last active May 22, 2019 06:11
[An Introduction to Flutter: The Interface] Basic scroll
Container(
child: SingleChildScrollView(
child: Text('long lorem text'), // any other widget can be here
),
)
@termosa
termosa / wrap_example.dart
Last active May 22, 2019 06:12
[An Introduction to Flutter: The Interface] Wrap example
class WrapExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
direction: Axis.vertical,
children: [
Item(),
Item(),
Item(),
],
@termosa
termosa / simple_flexible_slider_layout.dart
Last active May 22, 2019 06:12
[An Introduction to Flutter: The Interface] Simple flexible slider layout
class SliderExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Container(
child: Center(
@termosa
termosa / simple_slider_layout.dart
Last active May 22, 2019 06:12
[An Introduction to Flutter: The Interface] Simple slider layout
class SliderExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 300,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.network('http://lorempixel.com/300/200/city/'),
SliderButtons(),
@termosa
termosa / stack_example.dart
Last active May 22, 2019 06:12
[An Introduction to Flutter: The Interface] Stack example
class StackExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: Stack(
textDirection: TextDirection.ltr,
children: [
Circle(size: 120, color: Color(0xFFF44336)),
Positioned(
@termosa
termosa / extract_direction_from_context.dart
Last active May 22, 2019 06:13
[An Introduction to Flutter: The Interface] Extract text direction from the context
Widget build(BuildContext context) {
TextDirection dir = Directionality.of(context);
return Text(dir == TextDirection.ltr ? 'left to right' : 'right to left');
}