Skip to content

Instantly share code, notes, and snippets.

const Color GRAY_COLOR = Colors.grey;
const Color BROWN_COLOR = Colors.brown;
const Color RED_COLOR = Colors.red;
const Color ORANGE_COLOR = Colors.orange;
const Color BLUE_COLOR = Colors.blue;
const Color GREEN_COLOR = Colors.green;
const Color WHITE_COLOR = Colors.white;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Drag and Drop Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.green),
routes: <String, WidgetBuilder>{
DragTarget(
builder: (context, List<String> candidateData, rejectedData) {
return Center(
child: isSuccessful
? Padding(
padding: EdgeInsets.only(top: 100.0),
child: Container(
color: Colors.yellow,
height: 200.0,
width: 200.0,
Draggable(
data: 'Flutter',
child: FlutterLogo(
size: 100.0,
),
feedback: FlutterLogo(
size: 100.0,
),
childWhenDragging: Container(),
)
AnimationController _animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
Animation _animation = Tween(begin: 0.0, end: -0.15).animate(
CurvedAnimation(curve: Curves.ease, parent: _animationController));
Animation transformAnimation = BorderRadiusTween(
begin: BorderRadius.circular(125.0),
end: BorderRadius.circular(0.0).animate(type_of_animation);
/////////////// OR ///////////////
Animation transformAnimation = Tween<BorderRadius>(
begin: BorderRadius.circular(125.0),
end: BorderRadius.circular(0.0).animate(type_of_animation);
Animation _animation = Tween(begin: 0.0, end: 1.0).animate(type_of_animation);
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show SynchronousFuture;
class AppLocalizations {
AppLocalizations(this.locale);
final Locale locale;
static void setLocale(BuildContext context, Locale newLocale) async {
_MyAppState state = context.ancestorStateOfType(TypeMatcher<_MyAppState>());
state.setState(() {
state.locale = newLocale;
});
}